Java

Java

Java

Topics on Semeru (Java) on IBM Z

 View Only
  • 1.  Java 11 files as scripts on z/OS

    Posted Mon March 18, 2024 08:09 PM

    Java 11 allows you to execute single file source code programs without a separate compilation step. So, given HelloWorld.java you can run it from the source file with:

    java HelloWorld.java

    This works fine on z/OS.

    Java 11 also allows you to run a Java program as a script with a shebang, e.g. HelloWorld (without .java extension):

    #!/usr/lpp/java/J11.0_64/bin/java --source 11
    class HelloWorld                            
    {                                            
        public static void main(String args[])   
        {                                        
            System.out.println("Hello World");   
        }                                        
    }                                            

    Should run with the command

    ./HelloWorld

    This doesn't seem to work on z/OS. I get the message:

    error: no filename

    Does anyone have this working on z/OS? Any ideas what I might be doing wrong? I tried with a UTF8 file instead of EBCDIC, but that seemed to be further from working (I don't think the shebang was recognized for UTF8).

    Thanks

    Andrew Rowley



    ------------------------------
    Andrew Rowley
    ------------------------------


  • 2.  RE: Java 11 files as scripts on z/OS

    Posted Mon March 25, 2024 04:38 PM

    Hello Andrew,

    Hope all is well with you. Thank you for reporting this issue. The use of single-file Java source code programs,  supplied as a UNIX script shebang file, is not currently supported on Semeru SDKs on z/OS [1]. The workaround is to put the source into a *.java file as you have noted.

    The root cause is still under investigation by the team.

    Regards,
    Joran


    [1] https://www.ibm.com/docs/en/semeru-runtime-ce-z/11?topic=support-known-issues-limitations




  • 3.  RE: Java 11 files as scripts on z/OS

    Posted Mon April 01, 2024 08:58 PM

    Thanks Joran,

    This would be a useful function to make scripting with Java a little simpler.

    Andrew Rowley



    ------------------------------
    Andrew Rowley
    ------------------------------