I have a java project with processing elements that compiles and runs fine inside of Eclipse, but I need to export it to an executable. When I do this via Eclipse's export wizard, it produces a jar, but that jar produces runtime errors when it's double clicked or called from the command line. First it was giving me this:
C:\Users\Rachel\School\MQP>java -jar Simworm14.jar
Catched MalformedURLException: Could not open InputStream for URL 'rsrc:gluegen-
rt-natives-windows-amd64.jar', while addNativeJarLibsImpl(classFromJavaJar class
com.jogamp.common.os.Platform, classJarURI jar:rsrc:gluegen-rt.jar!/com/jogamp/
common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar
): [ rsrc:gluegen-rt.jar -> rsrc: ] + gluegen-rt-natives-windows-amd64.jar -> sl
im: jar:rsrc:gluegen-rt-natives-windows-amd64.jar!/
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: Can't loa
d library: C:\Users\Rachel\School\MQP\gluegen-rt.dll
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1706)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:551)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:96)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:414)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:388)
at com.jogamp.common.os.Platform$1.run(Platform.java:203)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:173)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:62
44)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:16
25)
at processing.core.PApplet.run(PApplet.java:2177)
at java.lang.Thread.run(Thread.java:662)
So I tried pasting gluegen-rt.dll into the given directory, and then it gave me this error instead:
C:\Users\Rachel\School\MQP>java -jar Simworm14.jar
Catched MalformedURLException: Could not open InputStream for URL 'rsrc:gluegen-
rt-natives-windows-amd64.jar', while addNativeJarLibsImpl(classFromJavaJar class
com.jogamp.common.os.Platform, classJarURI jar:rsrc:gluegen-rt.jar!/com/jogamp/
common/os/Platform.class, nativeJarBaseName gluegen-rt-natives-windows-amd64.jar
): [ rsrc:gluegen-rt.jar -> rsrc: ] + gluegen-rt-natives-windows-amd64.jar -> sl
im: jar:rsrc:gluegen-rt-natives-windows-amd64.jar!/
Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: C:\Users\
Rachel\School\MQP\gluegen-rt.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
at java.lang.Runtime.load0(Runtime.java:770)
at java.lang.System.load(System.java:1003)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoad
erBase.java:551)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.ja
va:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNIL
ibLoaderBase.java:96)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.j
ava:414)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrar
y(DynamicLibraryBundle.java:388)
at com.jogamp.common.os.Platform$1.run(Platform.java:203)
at java.security.AccessController.doPrivileged(Native Method)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:173)
at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82)
at processing.opengl.PJOGL.initSurface(PJOGL.java:250)
at processing.opengl.PGraphicsOpenGL.initPrimary(PGraphicsOpenGL.java:62
44)
at processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:16
25)
at processing.core.PApplet.run(PApplet.java:2177)
at java.lang.Thread.run(Thread.java:662)
After some googling, it appears this dependency issue might be a bug with jogl: https://java.net/jira/browse/JOGL-346 but I find it hard to believe that nobody has been able to export any processing applications from Eclipse. There's got to be a way, hasn't there?
Any suggestions?
Processing requires native libraries, which it doesn't look like you're including. You need to at least put the JOGL jar for the system you're on, but that won't help you deploy to other systems.
Shameless self-promotion: I wrote a tool that helps you create self-extracting runnable jar files that handle Processing's native libraries automatically so it works on every system: http://StaticVoidGames.com/SvgExe/
Related
Hey I am making a game in java using slick and run into all these errors. It works on my friend's computer but not on mine. I've tried on both mac and pc.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.lwjgl.Sys$1.run(Sys.java:73)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:95)
at org.lwjgl.Sys.<clinit>(Sys.java:112)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at Game.start(Game.java:37)
at Main.main(Main.java:5)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
What does above exception mean??
I do have it in my class path.
The error message explains it all, you dont have a LWJGL on your classpath. You need to install it so as to get it working on your system.
Also you need to point the jvm to the location where the native files are located using a command line parameter -Djava.library.path="path/to/natives". JarSplice is an alternative to this
You may check this for details
The lwgjl native library cannot be found and loaded. Set the path to the folder where lwjgl.dll (if on Windows, on Mac probably liblwjgl.so) is located, with -D, for instance
java -Djava.library.path=C:\Java\ljwgl\libs com.mypackage.MyProgram
The library files must have a permission to be executed. Some computers may be configured to suppress any execution from USB stick so check.
If still does not work, try to call System.load(String fullFilePath) from your code, pointing to the location where the file clearly exists. If this works at the end, you can use this function to load library without name alterations and path assumptions. If does not, it may be wrong achitecture (64 vs 32 bit, permission problems (not executable) or the library file is just broken.
I set up a JRI project for NetBeans 7.4 using 32-bit R 3.0.2 and Java jdk1.7.0_45, on Windows 7, using the steps outlined here.
When I called
Rengine.versionCheck()
I got the following
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: C:\Program Files\R\R-3.0.2\library\rJava\jri\jri.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
at rjava.RJava.main(RJava.java:40)
Java Result: 1
Following the suggestions here, I copied all of the dlls from
C:\Program Files\R\R-3.0.2\bin\i386
to the directory containing java.exe. I also right-cliked on the project and selected
Properties:Run:VM Options
and added
-Djava.library.path="C:\Program Files\R\R-3.0.2\library\rJava\jri;C:\Program Files\R\R-3.0.2\library\rJava\jri\i386"
The problem persisted. I tried prepending the following to my code.
System.loadLibrary("jri");
This resulted in
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\R\R-3.0.2\library\rJava\jri\jri.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at rjava.RJava.main(RJava.java:39)
Java Result: 1
I have done everything suggested here but the problem persists.
I had to restart NetBeans. That fixed the problems.
In fact, I found this part unnecessary.
Properties:Run:VM Options
-Djava.library.path="C:\Program Files\R\R-3.0.2\library\rJava\jri;C:\Program Files\R\R-3.0.2\library\rJava\jri\i386"
I made a java class using the library Jaudiotagger, and it runs without problems. I then made a jar out of it and I got NoClassDefFoundError. Here's how it went:
I put the main class id3tag.java and the library jaudiotagger-2.0.3.jar in a folder and compiled using the command line. The program ran smoothly without problems.
javac -cp .;jaudiotagger-2.0.3.jar id3tag.java
java -cp .;jaudiotagger-2.0.3.jar id3tag
I then created the manifest and the jar file.
echo Main-Class: id3tag >manifest.txt
jar cvfm id3tag.jar manifest.txt id3tag.class jaudiotagger-2.0.3.jar
I got the following output:
added manifest
adding: id3tag.class(in = 5952) (out= 2997)(deflated 49%)
adding: jaudiotagger-2.0.3.jar(in = 811441) (out= 740599)(deflated 8%)
I then ran the jar file, and got "A Java Exception has occurred.". I also tried:
java -jar id3tag.jar
And I got the output:
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaudiotagger/tag/
FieldDataInvalidException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
at java.lang.Class.getMethod0(Class.java:2694)
at java.lang.Class.getMethod(Class.java:1622)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.jaudiotagger.tag.FieldDataInval
idException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 6 more
I then replaced all (both) error classes used from Jaudiotagger with Exception and recreated the jar. Now the same thing happens as for seemingly all other jar files when I run them (with Java(TM) Platform SE binary, or through writing id3tag.jar in the command prompt) - nothing. java -jar, however, works and gave me a runtime error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaudiotagger/audi
o/AudioFileIO
at id3tag.tagSong(id3tag.java:112)
at id3tag.tagAlbum(id3tag.java:82)
at id3tag.tagArtist(id3tag.java:40)
at id3tag.main(id3tag.java:170)
Caused by: java.lang.ClassNotFoundException: org.jaudiotagger.audio.AudioFileIO
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 4 more
It seems like the entire library just doesn't do shit for me. How do I fix this, and how do I get jar files to run without java -jar? (Also, how do I get the full pile'o'errors in case someone needs it, rather than just having it say "x more"?)
I'm not very savvy with this kinda shit so the more specific the answer, the better. Thanks.
I'm on windows 8 and latest java (1.7.0_17).
this is informing you that you have no main class, as you might or might not already know all programs in almost all non web based programming languages must have a main class to start from. In java it looks like this
public static int main(String[] args){
}
The message is informing you that this class is no longer there, this could be a compiler error or something entirely different.
please try downloading the library again, and downloading eclipse ide for java ee developers.
this ide has a built in compiler that will work better than a command line sometimes.
i hope this helped.
I worked around it by including the org folder from jaudiotagger in my .jar instead of the actual .jar file, and I then used a .bat file to run it instead of running the .jar directly. Feel free to add your own answer if you find a better solution, and I'll check back.
I extracted jaudiotagger-2.0.3.jar with winrar so that the org folder was in the same folder as my main class. Then I could compile and run the main class simply by:
javac id3tag.java
java id3tag
I then created the manifest file the same way as before, and created the jar:
jar cvfm id3tag.jar manifest.txt id3tag.class org
The jar file worked with java -jar id3tag.jar, but simply writing id3tag.jar still did nothing. Turns out it's because jar files are by default run by the javaw.exe file, so you have to right click the jar file -> open with -> choose default program and navigate to the java.exe file in your java folder (just search the folder). Running the .jar then gets you "Error: Could not find or load main class path\id3tag.jar". I worked around this by using a .bat file. I entered
java -jar path\id3tag.jar
into Notepad and saved as whatevername.bat (save as type: all files).
I created a new question for getting the .jar file to work properly. See .jar error - could not find or load main class.
I'm attempting to run Apache Ant for the purpose of compiling OpenGTS. While attempting to run any "ant" command I'm getting the following output:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/launch/Launcher
Caused by: java.lang.ClassNotFoundException: org.apache.tools.ant.launch.Launcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.apache.tools.ant.launch.Launcher. Program will exit.
Previously I was getting a message stating "JAVA_HOME is not defined correctly" and after reading several forum threads, was able to solve that by updating the path:
export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
Another thread stated a "CLASS PATH" issue but if I'm able to run "ant" anywhere in the terminal, wouldn't the path be correct? Thanks in advance.
Make sure to set ANT_HOME to the directory where you installed ant. Refer to Installling Apache Ant.
You need to export ANT_HOME too, just make sure it is installed first on your system
export ANT_HOME="/usr/local/ant";
In my case it was a wrong permission on /opt/ant/lib folder.
I'm trying to create a simple Java Agent program before I implement the real thing. I cannot get it to run. Clearly I have some sort of configuration or class path problem. No amount of looking and trying has lead to me the problem.
If I run:
java -cp ./demoAgent.jar -javaagent:./demoAgent.jar com.kingtigerbooks.demoMod.Main
I get the following error:
Exception in thread "main" java.lang.ClassNotFoundException: com.kingtigerbooks.demoAgent.Agent
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:280)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
FATAL ERROR in native method: processing of -javaagent failed
Abort trap
I'm running this on my Mac. The jar file with the agent is in the current directory. The manifest for the jar file looks like this:
Manifest-Version: 1.0
Premain-class: com.kingtigerbooks.demoAgent.Agent
Can-Redefine-Classes: true
If smells like a class path problem, but as you can see I have included the jar on the class path. Any help would be appreciated. Its a very simple project.
Problem solved. I had a bad jar file. The agent jar file did not contain the agent class. By building the correct jar file and putting the fully qualified path to the jar on in the javaagent parameter it all works.
when you run an agent, you do not add the agent jar to the normal classpath.
as a side note, you can add -verbose:class to the command line to get info about the class loading process.