0

My platform has ubuntu 18.04.3 and openjdk version "1.8.0_242".

I'm running someone's executable jar file which references javax.vecmath.Vector3d, but the the openjdk vm generates NoClassDefFoundError for that class, as displayed below. The javax class is installed on my system in /usr/share/java/vecmath.jar, I've verified that it contains javax.vecmath.Vector3d, so I provide that jar in the '-cp' option:

% java -cp /usr/share/java/vecmath.jar -jar cameraCalc.jar

But I get this error:

java -cp /usr/share/java/vecmath-1.5.2.jar  -jar cameraCalc.jar 
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: [Ljavax/vecmath/Vector3d;
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: javax.vecmath.Vector3d
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:419)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
    ... 7 more

Why can't the jvm find that class even though it's in the vecmath.jar provided as a '-cp' option?

Thanks Tom

Tomasso
  • 693
  • 2
  • 9
  • 17
  • It's part of the Java3d api. Hint: googling "java vector3d docs" will almost always find me the official documentation for a class (replacing vector3d with whatever class I'm searching for). – NomadMaker Mar 05 '20 at 22:50
  • I've installed both libjava3d-java and libvecmath-java, which put jar files into /usr/share/java/j3dcore.jar, /usr/share/java/j3dutils.jar, and /usr/share/java/vecmath.jar. Of those, only vecmath.jar contains Vector3d - so I provide that jar as a "-cp" option but the jvm still gives "java.lang.NoClassDefFoundError: [Ljavax/vecmath/Vector3d;" – Tomasso Mar 05 '20 at 23:01

1 Answers1

0

My problem was due to running an executable jar file that does not contain all needed classes. From the documentation:

When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.

So "-cp" options will be ignored when running an executable jar file.

Tomasso
  • 693
  • 2
  • 9
  • 17