I have a big project and runs well in Eclipse. I build a runnable jar file by eclipse. When I put the jar file directly on the desktop it runs well, however if I make a new folder and move the jar file to the new folder, it does not work correctly, the output file is empty.. No errors appear.
Related
I have been adding modifications to a Java application that runs on a server using an applet. On the server, there is just the jar file, and an index.html page that opens the applet.
Now, I am trying to test the new version of the app on my computer before putting it on the production server, and it doesn't work : the application doesn't connect with the MySQL DB (when I just run it from Eclipse it works, it is when I try to run the jar file from my browser that it doesn't work). I tried running the old app on my desktop the same way and it runs just fine, so I guess the problem is in my jar file.
I have opened the 2 jar archives to see what's inside, and here's what I get :
Old jar :
Different folders for the different packages of the app
bin folder
com folder
META-INF folder
org folder
.classpath file
.project file
java.policy.applet file
mysql-connector-java-5.0.8-bin.jar
And now, here is what's inside the new jar :
Different folders for the different packages of the app
META-INF folder
.classpath file
.fatjar file
.project file
java.policy.applet file
mysql-connector-java-5.0.8-bin.jar
settings.fatjar file
So my archive doesn't have the bin, com and org folders. It also has 2 additionnal files.
I don't know which settings should I use when exporting my jar in Eclipse to obtain the same content ?
Also, my new jar isn't signed, could this have something to do with my problem of database access ?
I'll answer my own question, as I found the solution :
The jar needs to be exported as a runnable jar
The option "extract required libraries into jar" must be selected
The jar must be signed (self signed works as it is an internal app, so no need to pay a certificate)
Now it works :)
While execute the jar file. i found this exceptions. But when i tried to double click the .jar file. It shows
if anyone know whats the error. just tell me..
Your jar needs the Jcalendar classes to be executed properly...
is the Jcalendar. jar in the classpath??
For those who Got this error "Java Exception Has Occurred" Try this
I tried the solution in Netbeans. While creating a jar file for swing applications. Your .jar file is placed inside the dist folder. Inside the dist folder you have one lib folder and your .jar folder.
Just select the two lib and jar files and copy and paste in some other new folder. And now you double click your jar file. now your jar file is working fine.
I have a plugin, and I need to add files from the .jar to the data folder.
So far I have tried numerous times and yet no avail. The file in my jar is called EffectList.txt and the output folder is plugins/MageSpells/EffectList.txt
I have created a Javafx project named MyProjectName in Netbeans 7.4 and I have added some external jars. Its running fine from Netbeans.
After Clean and Build dist folder is created and few sub folder is created like 1-lib(containing all external jar file),
2-run321...(containing MyProjectName.jar,jnlp,html...etc), 3-webfile,
4-MyProjectName.html, 5-MyProjectName.jar(this executable jar), 6-MyProjectName.jnlp
MyProjectName.jar(5-MyProjectName.jar(this executable jar)) running fine from dist folder.
But when i copy MyProjectName.jar somewhere else and try to run, it is not running .
It show Message Exception while running the application.
But when i put lib folder(1-lib(containing all external jar file)) it is running fine.
How can i run it only from MyProjectName.jar???
that is because you need those dependency jar files.
you can create a jar file by combining all those external jars
Try out this
Try to use this command:
java -jar MyProjectName.jar
This may help you.
Execute a .jar without the lib directory is imposible, because your main .jar will need those .jar depended files. If you need to move your MyProjectName.jar somewhere else and try to run it, you must move the lib directory too, or prove Thusitha' solution.
I would like to export my Java program, but I have run into problems. It exports fine but my resource files like my res folder and my sound folder aren't there. They are located in the project directory, so I don't know if that should be a problem. I am currently just using ImageIcon().getImage() to get my pictures and that works fine but when I export and run it the program runs but it doesn't have any pictures. Any help would be greatly appreciated
The problem is that once the images/sounds are inside the jar you must access them as a resource.
Image image = new ImageIcon(this.getClass().getResource("/image.gif")).getImage();
Make sure the images are really inside the jar opening the jar with winrar or similar if not add the folders as source folders in your buildpath.