I'm attempting to execute an executable JAR I generated using Eclipse for a Slick2D game project I'm trying to deploy, and I keep getting an error saying:
java.lang.UnsatisfiedLinkError: no lwjgl64 in java.library.path
I followed the Slick2D setup to the letter when setting up the project months ago. But up until now, I've always run through Eclipse, and have never attempted to run through a JAR.
To generate the JAR, I chose Export -> Runnable JAR, and I chose to package the required libraries into the JAR. I then tried to execute the JAR from the command line as so:
java -jar JAR_NAME.jar
After receiving the above error, I tried many different methods of getting this so-called lwjgl64 library onto the java.library.path, but to no avail.
So far I've tried:
Changing the native library location of lwjgl.jar in my Slick2D user library to the folder containing the lwjgl-natives-*.jar files, but those only have the 32-bit definitions in them, and I figured it was looking for a DLL, so...
I ran the following command instead:
java -jar JAR_NAME.jar -Djava.library.path="C:\slick2d"
But this produced the same result, even though that directory contains lwjgl64.dll, among other files.
I tried copying all of the dll/so files from C:\slick2d into a folder called natives in a source folder in Eclipse and using the following code to set it as the java.library.path:
System.setProperty("java.library.path", "libs");
System.setProperty("org.lwjgl.librarypath", new File("libs/natives").getAbsolutePath());
But this just resulted in yet another error:
java.lang.UnsatisfiedLinkError: Can't load library: C:\Users\packetpirate\workspace\GZS Redux\target\libs\natives\lwjgl64.dll
Does anyone have any insight into this problem? I'm not great at building projects, especially in Eclipse, so I've always had trouble with linking dependencies. I've thought of converting my project to Maven, but I wouldn't know where to start and how to set it up.
EDIT: I realized that the libs/natives folder was not copied to the target folder when I generated my JAR, and after copying it over, I was able to run the JAR, but I still get similar errors related to jinput-dx8_64 and jinput-raw_64, which are also in the same folder. It doesn't seem to affect the game's behavior, though...
Also, although I know this is a Slick2D specific thing... it seems to be loading my assets twice. The only way I can see this happening is if the Loading state is entered twice, which doesn't make sense.
Related
I am currently having a problem running a jar file created by eclipse.
Within eclipse I can run my project using the run function and the project runs exactly as expected.
The same applies to compiling and running the code from command line using javac Menu.java to compile and java Menu to run.
Both of these run correctly and do not return the error I receive when running the jar file.
The jar file was created in eclipse by exporting the project. But when i run the jar file the application refuses to response when opening any JFrames containing Java3d. Upon debugging the jar file i receive the error
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax/media/j3d/Canvas3D
This normally would lead me to believe that my CLASSPATH is incorrect but since the project runs from command line this doesn't seem likely.
Any help or pointers would be very helpful.
Thanks.
Found a solution which works.
Instead of simply creating a jar file, you can created a runnable Jar file.
When asked under library handling in the export process, selecting 'package required libraries into generated JAR' solves this issue and allows it to run on all computers, even ones without Java3D installed.
I'm currently working on a project where I'm using the LWJGL library and I just tried building a .jar out of it all, now the problem is that nothing happens when I try to start the .jar.
My only thought is that maybe the library didn't export correctly but I've been looking around at the other questions here for a while and I've have added everything correctly at the Dependencies tab in the Project Structure, the libraries I need are also in the Artifact Output Layout as extracted directories.
I just tried checking the stacktrace with cmd and it says that it can't find lwjgl in the library path so I'm guessing there's something I don't know about .jar files or something that's causing this error.
Here's the stacktrace:
Also in IntelliJ I've put "-Djava.library.path=lib\native" in VM options, is it possible that this doesn't apply to the .jar or something.
Help is appreciated!
There is a rather complicated process to make an executable jar with LWJGL. You need to use Jarsplice.
Jarsplice has 4 steps which are pretty self explanatory but here they are anyway:
1: Add Jars.
Add the jar you generated as well as all the libraries. That includes lwjgl.jar, and any other jars you used.
2: Add Natives.
Add all the natives you used in your project. These are the files you referenced using -Djava.library.path.
3: Main Class
Select the main class of your program. This could be something like com.example.game.EntryPoint.
4: Create Fat Jar
Click "Create Fat Jar" to create your executable jar!
You can also optionally create a Windows .exe, OSX .app, and Linux .sh executables as well.
Hello fellow programmers! I am writing a game at the moment, that uses the following libraries: LWJGL, OpenGL, Slick. I know the problems with simply exporting a JAR file from eclipse when using libraries like that, and I do use the JarSplice program to make a fat JAR. This has worked fine for about a month now, however, just recently it stopped working. Whenever I export the JAR from eclipse, and make it a fat JAR using JarSplice, I get this error:
Could not find or load main class Game.jar
META-INF (Located in the fat JAR):
Manifest-Version: 1.0
Launcher-VM-Args:
Launcher-Main-Class: cubix.main.Cubix
Main-Class: org.ninjacave.jarsplice.JarSpliceLauncher
Please note that the main method of the program is located in the Cubix.class, which is located in cubix.main.Cubix'
I have never came across this error before, and it is driving me insane. If any additional information is required, please feel free to ask.
EDIT:
I might also add that if I export any other project this way (using the same libraries and using jarsplice to build a fat JAR) it works just fine. I am only experiencing this problem with this specific project in eclipse. However, when I run Cubix in eclipse debugger, it runs just fine.
Try couple of things :1 check the content of the file, use jar -tf see everything is present2. can you try running this file from command/terminal.3 if all above is good, compile Cubix.java from terminal and place this .class file in jar file manually and check.
I'm sorry for posting this. The problem wasn't that it couldn't find the main class but rather I had typed the command line wrong. I typed: 'java Cubix.jar -jar' rather than 'java -jar Cubix.jar'. Also, after fixing the command line, it gave me the stack trace for the error that was overlooked by eclipse, and that one of the textures that needed to be loaded was case sensitive.
ok I have been search the internet all day and I have tried everything I have seen so i am wondering if someone could help.
I have a class that references a jar file which i have copied into my workspace in the lib folder the jar is: Classifier4J.jar, My class run perfectly on the console no error at all. When I try to package the .jar together and run the .jar from another program it gives me this error:
Exception in thread "pool-2-thread-1" java.lang.NoClassDefFoundError: net/sf/classifier4J/bayesian/IWordsDataSource...(10 more)
So clearly when i create the .jar its not able to reference the classifier4j library that it needs.
Things I have tried:
-Configure my build path
-Change the manifest file
-packaged the .jar with my .jar
-in eclipse went to file>export>java>runnable .jar then references the libraries
and many other things and nothing worked.
If anyway has had a similar issue or knows why this is happening could you please help me its really wrecking my head. Is this a problem with eclipse? can it be done through eclipse?
Thanks in advance
Jay
Ok after hours of looking at the problem i finally found the solution, When I output my classes as a .jar file I pointed it to my manifest file. I couldn't find what i was doing wrong because it didn't work. I decided to look at what was actually put into the jar and i saw that eclipse wasn't putting the correct manifest file i asked it to into the jar. It was putting a new one that looked like:
Manifest-Version: 1.0
where it should have looked like:
Manifest-Version: 1.0
Class-Path: ../lib/Classifier4J.jar
where the lib folder was back a directory from where my jar was. Everything is working perfectly now. Thank you for all your help.
Jay
It is hard to understand what you are actually trying to do, what you have actually tried, and what you expect to work, but I think the clue is here:
packaged the .jar with my .jar
This seems to imply that you are trying to create an "executable JAR" that contains all of the dependent JARs ... as-is. That won't work, an "executable JAR" cannot contain other JARs. (Well is can ... but you can't put them on your application's classpath without doing seriously complicated things.)
Basically, you have two options:
Don't try to include the dependent JARs in your (executable or not) application JAR. Keep them separate, and configure the execution classpath to include them. (And beware that for an executable JAR, the execution classpath must be configured as a Manifest entry. If you use java -jar ..., the -cp argument and $CLASS_PATH are ignored!)
Create a so-called "uber-JAR" by exploding the application JAR and all of the dependent JARs into a single directory and then creating a single JAR (with a suitable Manifest) from the lot. Your build tool or IDE may have support for this via some plugin.
I personally prefer the former approach ... combined with an "installation directory" for the application and a wrapper script. With the latter approach you make it hard for the user (or deployer) to mix-and-match versions of dependent JARs. Furthermore, the "uber-JAR" approach could conflict with a 3rd-party library's license.
At last, maybe we can get somewhere
.... the .jar file is ran from a tomcat application its a simple adapter for log files that all.
OK. You should have mentioned that before, because it is a critical piece of information. In order for a JAR file to usable within in a web container (i.e. in the same JVM as Tomcat), there must be a copy of the JAR file and all of its dependent JAR files in the web container's directory tree. There are two choices. Either you put them in the webapp's lib directory (i.e. webapp/WEB-INFO/lib) or you put them in the shared library directory ... which depends on which version of Tomcat you are using.
(The "executable JAR" approach won't work here. The classpath stuff you put in the Manifest is irrelevant. And nesting JAR files won't work either.)
The particular library is not included in your jar. You could either try to fix your eclipses build configuration to include that library, or add the library's jar to the classpath when you run the program.
The later may be easier. Just add the following to the command when you execute your program.
java -cp yourjar.jar;thelibrarysjar.jar com.your.Mainclass
You need to understand that NoClassDefFoundError hardly ever means that the identified class can't be found. Far more often, the class was found, but something prevented it from being successfully loaded.
The two most likely problems are -
Some other missing class that prevents the named class from being "verified".
Some incompatibility due to a different version of a class (usually another class) being used in compilation vs execution.
In your case it's most likely that when you have the problem you're picking up a different (and incompatible) version of some other jar, vs the environment during compilation.
I created a runnable JAR with Eclipse for a small SLick2D game. No matter what settings I tried, I always received some sort of error, whether it be UnsatisfiedLinkError, or some class not being found.
I tried JARSplice, but that didn't work either.
Can anyone give me the steps to creating a runnable jar out of an Eclipse project?
The first thing you need is to somehow include the native libraries. You'll find them in the .zip you download from the lwjgl site.
I can recommend using JarSplice to package them. Make sure that when you specify what class it is supposed to run you do not use the default package (This is bad practice anyway). Specify the whole package path (e.g. package1.package2.Main), and it should run.
Use the packaged JAR generated by eclipse as your "input" jar of jarSplice.
If you use your command prompt to try and run your .jar after jarsplicing it, or using the manifest method, or whatever, you would go to the directory your .jar is in and type
java -jar YourGameNameHere.jar
This will give you the errors on why it will not run.