(9921) Java jar files and corruptions?

Archive of the OpenVMS Ask the Wizard (ATW) questions and answers database.
Locked

Topic author
User
Visitor
Posts: 0
Joined: Mon Jan 10, 2022 8:16 am
Reputation: 0
Status: Offline

(9921) Java jar files and corruptions?

Post by User » Sun Nov 28, 2004 8:26 am

I'm trying to utilise a jar file in my java code, without a succes. I have problems with correctly specifying the classpath.

Here follows an example. I have the following class file:

Code: Select all

luokkapolku/example/run.class
(the package is luokkapolku.example).

Then, I have a jar-file:

coreO.jar

in the directory /luokkapolku

The jar file contains class JSci/maths/DoubleMatrix. The application (run.class) prints out "Ok" and tries to create a new DoubleMatrix:

Code: Select all

package luokkapolku.example;

public class run {

    public static void main(String[] args)
    {
        System.out.println("Ok");
        JSci.maths.DoubleMatrix d = new JSci.maths.DoubleMatrix(10,10);
    }
The application runs fine in windows environment using the command:

Code: Select all

java -cp ".;luokkapolku\coreO.jar" luokkapolku.example.run
When I try to run it in your OpenVMS testdrive environment with the command:

Code: Select all

$ java -cp ".:luokkapolku/coreO.jar" luokkapolku.example.run
or

Code: Select all

$ java -cp ".:luokkapolku.dir/coreO.jar" luokkapolku.example.run
I get the error message:

Code: Select all

Exception in thread "main" java.lang.NoClassDefFoundError:
 JSci/maths/DoubleMatrix
        at luokkapolku.example.run.main(run.java)
What went wrong? I have checked your tip number 5051 about classpath, but that's not about using the -classpath option with the java command.

Here is some debug information from the java launcher:

Code: Select all

$ java -cp ".:luokkapolku/coreO.jar" luokkapolku.example.run
----_JAVA_LAUNCHER_DEBUG----
JRE path is /sys$common/java$142/jre
jvm.cfg[0] = ->-classi
jvm.cfg[1] = ->-nativ
jvm.cfg[2] = ->-gree
1 micro seconds to parse jvm.cfg
Does `java$jvm_shr' exist ... yes.
JVM path is java$jvm_shr
1 micro seconds to LoadJavaVM
JavaVM args:
    version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 3
    option[ 0] = '-Djava.class.path=.'
    option[ 1] = '-Djava.class.path=.:luokkapolku/coreO.jar'
    option[ 2] = '-Dsun.java.command=luokkapolku.example.run'
1 micro seconds to InitializeJVM
Main-Class is 'luokkapolku.example.run'
Apps' argc is 0
1 micro seconds to load main class
----_JAVA_LAUNCHER_DEBUG----
Exception in thread "main" java.lang.NoClassDefFoundError:
 JSci/maths/DoubleMatrix
        at luokkapolku.example.run.main(run.java)

------------------------------

$ java -cp ".:luokkapolku.dir/coreO.jar" luokkapolku.example.run
----_JAVA_LAUNCHER_DEBUG----
JRE path is /sys$common/java$142/jre
jvm.cfg[0] = ->-classi
jvm.cfg[1] = ->-nativ
jvm.cfg[2] = ->-gree
1 micro seconds to parse jvm.cfg
Does `java$jvm_shr' exist ... yes.
JVM path is java$jvm_shr
1 micro seconds to LoadJavaVM
JavaVM args:
    version 0x00010002, ignoreUnrecognized is JNI_FALSE, nOptions is 3
    option[ 0] = '-Djava.class.path=.'
    option[ 1] = '-Djava.class.path=.:luokkapolku.dir/coreO.jar'
    option[ 2] = '-Dsun.java.command=luokkapolku.example.run'
1 micro seconds to InitializeJVM
Main-Class is 'luokkapolku.example.run'
Apps' argc is 0
1 micro seconds to load main class
----_JAVA_LAUNCHER_DEBUG----
Exception in thread "main" java.lang.NoClassDefFoundError:
 JSci/maths/DoubleMatrix
        at luokkapolku.example.run.main(run.java)
Last edited by marty.stu on Tue Jan 11, 2022 10:01 am, edited 2 times in total.


Wizard
Visitor
Posts: 0
Joined: Mon Jan 10, 2022 8:17 am
Reputation: 0
Status: Offline

Re: (9921) Java jar files and corruptions?

Post by Wizard » Mon Nov 29, 2004 8:26 am

As was reported in a later missive from the questioner, the root cause of the problem seen was an error in the record structure chosen for the jar file. With the following command:

Code: Select all

$ set file/attr=(rfm:stmlf,ra:cr) coreo.jar
issued on the jar-file, the jar file has the correct format, the operation then succeeds.

Do also check the settings for Java, as C itself offers various format default settings on recent OpenVMS releases.
Last edited by marty.stu on Tue Jan 11, 2022 10:02 am, edited 1 time in total.

Locked