I'm working on a Java program that uses Processing to render images. I have the core.jar file in my library folder and the program compiles fine on Eclipse. The problem is that I need to be able to run the program from the command line and it doesn't work.
This is what I'm doing:
First I compile using:
javac -cp "./../lib/*" -source 1.8 -target 1.8 -verbose generative/components/examples/VisTests.java
which gives me the following output:
warning: [options] bootstrap class path not set in conjunction with -source 8
[parsing started SimpleFileObject[/Users/user/Documents/Work/Research/CodeDev/MyProject/src/generative/components/examples/VisTests.java]]
[parsing completed 25ms]
[search path for source files: .,../lib/peasycam.jar,../lib/gluegen-rt-natives-macosx-universal.jar,../lib/cmaes_java.jar,../lib/commons-math3-3.6.1.jar,../lib/jogl-all.jar,../lib/cma-es-custom.jar,../lib/gluegen-rt.jar,../lib/core.jar,../lib/jogl-all-natives-macosx-universal.jar,../lib/peasy-math.jar]
[search path for class files: /Library/Java/JavaVirtualMachines/jdk-15.0.2.jdk/Contents/Home/lib/modules,.,../lib/peasycam.jar,../lib/gluegen-rt-natives-macosx-universal.jar,../lib/cmaes_java.jar,../lib/commons-math3-3.6.1.jar,../lib/jogl-all.jar,../lib/cma-es-custom.jar,../lib/gluegen-rt.jar,../lib/core.jar,../lib/jogl-all-natives-macosx-universal.jar,../lib/peasy-math.jar]
[loading /modules/java.base/java/util/ArrayList.class]
[loading /modules/java.base/java/util/Random.class]
[loading ../lib/core.jar(/processing/core/PApplet.class)]
[loading ../lib/core.jar(/processing/core/PConstants.class)]
[loading /modules/java.base/java/lang/Object.class]
[loading ../lib/peasycam.jar(/peasy/PeasyCam.class)]
[loading ./generative/components/Chromosome.class]
[loading ./generative/components/Environment.class]
[loading ./generative/components/Cell.class]
[loading ./generative/components/Organism.class]
[loading ./generative/components/Colony.class]
[loading ./generative/components/Simulation.class]
[loading ./generative/components/Colony3D.class]
[loading /modules/java.base/java/lang/String.class]
[loading /modules/java.base/java/lang/Deprecated.class]
[loading /modules/java.base/java/lang/annotation/Retention.class]
[loading /modules/java.base/java/lang/annotation/RetentionPolicy.class]
[loading /modules/java.base/java/lang/annotation/Target.class]
[loading /modules/java.base/java/lang/annotation/ElementType.class]
[loading /modules/java.base/jdk/internal/PreviewFeature.class]
[loading /modules/java.base/jdk/internal/PreviewFeature$Feature.class]
[checking generative.components.examples.VisTests]
[loading /modules/java.base/java/io/Serializable.class]
[loading /modules/java.base/java/lang/AutoCloseable.class]
[loading ./generative/components/CommonConsts.class]
[loading ../lib/core.jar(/processing/core/PImage.class)]
[loading ./generative/components/CommonFunctions.class]
[wrote generative/components/examples/VisTests.class]
[total 337ms]
1 warning
Then I run the program with:
java -cp ".:../lib/*" generative.components.examples.VisTests
which returns the following:
java.lang.NoClassDefFoundError: com/jogamp/opengl/GLCapabilitiesImmutable
at processing.opengl.PGraphicsOpenGL.createPGL(PGraphicsOpenGL.java:712)
at processing.opengl.PGraphicsOpenGL.<init>(PGraphicsOpenGL.java:569)
at processing.opengl.PGraphics3D.<init>(PGraphics3D.java:35)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at processing.core.PApplet.makeGraphics(PApplet.java:2266)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)
at processing.core.PApplet.initSurface(PApplet.java:10983)
at processing.core.PApplet.runSketch(PApplet.java:10922)
at generative.components.examples.VisTests.main(VisTests.java:138)
Caused by: java.lang.ClassNotFoundException: com.jogamp.opengl.GLCapabilitiesImmutable
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 12 more
java.lang.RuntimeException: com/jogamp/opengl/GLCapabilitiesImmutable
at processing.core.PApplet.makeGraphics(PApplet.java:2299)
at processing.core.PApplet.createPrimaryGraphics(PApplet.java:2345)
at processing.core.PApplet.initSurface(PApplet.java:10983)
at processing.core.PApplet.runSketch(PApplet.java:10922)
at generative.components.examples.VisTests.main(VisTests.java:138)
I'm using a MacBook Pro with macOS 11.4 (Big Sur).
As far as I understand all the required .jar files are in place and the process that I'm using works (as per my testing with other programs that do not use Processing). So what could I be missing?
Edit: I have just recompiled without using the -source and -target flags and the issue has been resolved. I'll look into what could have been causing the problem. Thanks to the people that commented.