ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problem with the RUNJVA command

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with the RUNJVA command

    I'm trying to run a .jar file from a CLP. I know the java works and I can execute the .jar directly from command line, but when trying to run it from a CLP I keep getting an error that java.version does not match JAVA_HOME environment variable. I'm not sure what I am doing wrong, as I set the environment variable to jdk6 which is version 1.6 and I set java.version to 1.6. I can see that setting JAVA_HOME to jdk6 uses version 1.6 using the java *version command. Below is the command I am trying to use. Any help is appreciated.

    Code:
     RMVENVVAR  ENVVAR(JAVA_HOME)                               
     MONMSG     CPF0000                                         
     ADDENVVAR  ENVVAR(JAVA_HOME) VALUE('/QIBM/ProdData/+       
                Java400/jdk6')                                  
                                                                
     SBMJOB     CMD(RUNJVA +                                    
                  CLASS(com.company.rms.Main) +             
                  PARM(&SYSTEM &SALECUBE &SALESEG &STORE +      
                  &ITEM &CUSTOMER) +                            
                  CLASSPATH('.:/HOME/PROSDATA/lib/RMSXML.jar:+  
                  /QIBM/ProdData/Java400/jdk6:+                 
                  /HOME/PROSDATA/lib/jt400.jar:+                
                  /HOME/PROSDATA/lib/log4j-1.2.15.jar:+         
                  /HOME/PROSDATA/lib/jog4j.properties') +       
                  PROP((java.version '1.6'))) +                 
                  JOB(PRC_PPSXML)

  • #2
    Re: Problem with the RUNJVA command

    Warren, the java.version variable is supposed to be a read-only variable. You are not supposed to set it.

    In older versions of Java, IBM did allow you to set it (which was weird because it was not allowed on other platforms... you could only set the java.version on OS/400, for example, but not on Windows, Mac, Linux, or Unix.)

    However, in new versions (starting with the 32-bit version of 1.5, and continuing with 1.6) you cannot set java.version. Instead, you should be controlling which JVM is used by setting the JAVA_HOME environment variable. It looks like you're already doing this (setting JAVA_HOME) so I think if you just remove the java.version setting, everything should work fine.

    Comment


    • #3
      Re: Problem with the RUNJVA command

      I tried your suggestion Scott, but still had some issues. After doing some more research, I changed it to call a shell script with the STRQSH command and that seems to have mostly worked. Now I'm running into a problem where when exceptions are thrown, it never executes the catch blocks, but that is a java problem, not CLP. Thanks for your help.

      Comment


      • #4
        Re: Problem with the RUNJVA command

        Not sure why I'd matter whether you use STRQSH or RUNJVA... can you share your research?

        Comment


        • #5
          Re: Problem with the RUNJVA command

          My research was me looking for more examples of what others have already done at the company I work for. I found that most people had chosen to use a shell script to call Java programs. Once I put my classpath information and the call to the Java in the shell script, and changed to the STRQSH command, it just worked. I've included the shell script in case anyone can spot something I inadvertently changed between the RUNJVA and this that could have made it work.

          Code:
          # Set class path for java program
          LOCALCLASSPATH=.:/home/PROSDATA/RMSXML.jar
          LOCALCLASSPATH=$LOCALCLASSPATH:/home/PROSDATA/lib/jt400.jar
          LOCALCLASSPATH=$LOCALCLASSPATH:/home/PROSDATA/lib/log4j-1.2.15.jar
          LOCALCLASSPATH=$LOCALCLASSPATH:/home/PROSDATA/
          
          cd /home/PROSDATA
          
          
          # call the java program to create the XML files
          
          java -cp $LOCALCLASSPATH com.company.rms.Main $1 $2 $3 $4 $5 $6

          Comment


          • #6
            Re: Problem with the RUNJVA command

            In the RUNJVA classpath, you specified /HOME/PROSDATA/lib/RMSXML.jar, but in the QSH one you specified /home/PROSDATA/RMSXML.jar. Is it possible that this JAR file is not in the lib directory, but only the /home/PROSDATA directory?

            Also, in the RUNJVA example you specified /QIBM/ProdData/Java400/jdk6 and /HOME/PROSDATA/lib/jog4j.properties, which I strongly suspect are wrong. Why would these directories be in a classpath? PLus, the last one says "jog4j", and I strong suspect that it should be "log4j"... but probably shouldn't be there at all.

            Also, the QSH script changes your current working directory to /home/PROSDATA -- the RUNJVA does not (but perhaps you did that earlier in the calling CL program?)

            These commands run the same Java Virtual Machine under the covers, so assuming you give them the same parameters, they should work identically. I can't see why try/catch would fail under one and not under the other. Are you positive that the try/catch is related to whether to use RUNJVA vs QSH?

            Comment


            • #7
              Re: Problem with the RUNJVA command

              I am not sure that the try/catch is related to using QSH, as for the other things, the different class paths have to do with me moving stuff around to see if I could get it working when I was messing with the RUNJVA command, except for the jog4j, that was just a spelling mistake and explains why it didn't find the properties file.

              Comment

              Working...
              X