So after all those days I finally finished my work for school, but I need to export it to a jar file. My project includes for example LWJGL. I think he finds it, but I get this Exception:
java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException
and so on.
How can I fix this?
When you are exporting your jar file
Tick the check-box of
export generated class files and resources and also
export Java source files and resources
Then, you should have all the source files.
I already solved it. Someone told me to add this line to my source code:
System.setProperty("org.lwjgl.librarypath", new File("native").getAbsolutePath());
and it works after I created the "native" folder in my projects folder.
New problem any way is, that my text is only drawn, if I start my program with command line
Related
I'm facing a problem I have never had before when exporting my eclipse project with external library. I made a little program with spelling correction and I used the language tool library you can find here.
I put this library in the build path and correctly imported into my eclipse project. When I ask to export it into a runnable jar, Eclipse exports only the jar files into languageTool library, but this library contains also some txt and xml files. So when I try to launch the application from command line it gives me error because can't find this txt and xml files. I tried to add to my jar archive manually but obviously it doesn't work. How can I fix it?
Thanks for your time and forgive me for my bad english.
I'm in troubles.
I worked on a project on a wiktionary dump (that is a reaaaally huge file). Requirements asked that the dump file had to be passed as argument from command line. For making it easier I worked on NetBeans, I set all the parameters, put the dump file into the 'src' folder and everything went fine.
Requirements asked that the project had to be delivered as a jar file. I'm quite a newbie with jars, so I just copied netbeans src folder, compiled the code (from shell), removed the dump file -as it wasn't needed to be into the jar - and just did "compress as jar file".
Now comes the problem: When I run it from shell I get java.lang.reflect.InvocationTargetException caused by a java.net.MalformedURLException . I think the problem is that it looks for the dump only inside the jar, but actually the dump will be outside.. How can I fix it?
Don't know if it matters.. I'm working on ubuntu
Thanks everyone for your help!
So I have a small Java program with some gui that I have runnning in eclipse just fine. I followed the fatjar tutorial to create the .jar, but when I try to run the .jar the first gui window appears but none of the functions work. When I ran it in cp, clicking the button generated an exception basically saying some of the object types could not be resolved as type, all of which were from import libraries. Has anyone seen this before, I tried using this program jarfix for an issue similar to mine, but nothing.
Please define
When I ran it in cp
The format of the java command should look something like
java -cp /path/to/jars com.main.class
You could start locating the source of the problem by opening the jar file with an archive program (e.g. winzip) and look if the class / type is included in the jar file or not.
If it is there it might be a classpath issue. If it is not there something is wrong with building the jar file. Musn't the included jar file be set in the "Order and Export" tab in the java buildpath dialog?
I am not aware of fatjar. But I faced similar problem, might be somewhere it is linked to your issue.
In my case everything was working when I was running through eclipse, but when I created JAR using Eclipse I faced issue as what you are facing, but in my case it was issue of accessing resources inside JAR File.
So solution was,
Right Click -> Export as -> Jar, here check the box "Add Directory Entries" and then create the JAR. Ans all worked.
Above all, first you should check whether the jar which is generate is correct or not by just open it with winrar or similar tool and see all classes and resources are placed properly.
An alternative would to place all those jar files in the same folder. i.e. if your application jar file is App.jar and other dependencies are A.jar and B.jar. Then drop A.jar and B.jar in the same folder as App.jar.
If you double click on App.jar it will by taking the other dependencies in the same folder by default.
To be clear, i know there is a thread like this on stackoverflow and he uses eclipse while I use Intellij. Creating an executable jar in eclipse and intellij are different. So before downvote kindly consider my scenario. I created a simple java game using libgdx and want to export it in an executable jar. But before doing so, I experimented in creating a jar of the one in the tutorial video of official LIBGDX.This is the jar file Dload it here.. If you execute it opens then close again. But when i ran the project in intellij it runs without error.
This is the image i was expecting if i execute the jar file i created..
What is wrong when i tried to create a jar file?? Anyone?? Thanks
Just open your exported jar file like a zip archive and export your assets folder and libraries beside your jar file then test it again. Hope this helps.
My project runs fine from Eclipse.
But when I tried to make it into a jar file or executable file it doesn't work.
I used the option "Export-Runnable JAR file"
The following message appears just after the eclipse finished the exporting process
JAR export finished with wornings , see details.
the details were ..
Exported with compile warnings:Mario/src/Map.java
and the same for other classes like
Exported with compile warnings:Mario/src/Player.java
and so on.
So that I used the other option "Export - JAR file"
It works fine and nothing appears while exporting it from Eclipse.
But when I try to open the file it gives me
Couldn't find the main class:Frame.Program will exit
Somebody have any idea about what the problem is?
Your MANIFEST.MF file inside the META-INF dir should have a Main-Class attribute pointing to your main class.
The important thing for executable jar is Manifest. Make sure it exists and points to the correct class with main method