This question already has answers here:
Add image to JAR Java
(7 answers)
Closed 6 years ago.
I have 2 individual .java files, and in those files, I have taken in some buffered images, which are 3 .png files. I want to turn this grouping, the 2 java files and the 3 png images into a single file that can be opened and executed without a compiler. How do I do this?
You have to build a jar file for this. So you will be able to run your application by double clicking on your .jar file. If you are using netbeans to develop you can simply do it by right click on your application and by selecting clean and build.
I hope this link will help you.
Related
This question already has answers here:
Eclipse exported Runnable JAR not showing images
(8 answers)
Closed 7 years ago.
I'm trying to export my java file as a runnable .jar file using Eclipse. The procedure I'm doing is:
File > Export > Java > Runnable .jar, and my options are as follows:
http://gyazo.com/88ad22e9382e964e47a1a21200ff0f4b
My problem is, when I run the file in Eclipse, any imported pictures (e.g. a logo for the GUI application) shows up, but it doesn't show up in the exported .jar file.
I.e:
http://gyazo.com/4092e8756f4054ce00429d50c33c22af - in Eclipse
http://gyazo.com/7309d84f64832b22560ef023c9349a52 - running the .jar file
My images are in a folder called filesrc which is in the same folder as my project, as can be shown here:
http://gyazo.com/20f8191ee173e06638811c237f985c6f
What am I doing wrong? How can I make these images appear in the .jar?
Thanks
Make sure your exported .jar file contains the folder with your images. So lets assume that your images are in a folder called \images at the root of your JAR file.
In your code, you need to change the way your are getting these images to :
Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/plus.png"));
This question already has answers here:
Java creating .jar file
(5 answers)
Closed 8 years ago.
I decompile jar file using jd-gui app. I made some changes on it.
After that i try to compile main.java file which one include all packages & other java files.
Then it Shows classnotfound exception.
I need to it without using any IDE.
Please Help me.
Thanks in advance.
A JAR (http://en.wikipedia.org/wiki/JAR_%28file_format%29) file is a ZIP-compatible archive of your compiled classes and other binary resource.
Feel free to unpack/pack it or treat it the way you treat ZIP-archive, say using your favorite archiving tool, like 7zip.
You can even create a ZIP archive with the contents you wish your JAR to contain and simply change the file extension to .jar.
NOTE: in case you use compression for your ZIP-archive, because in that case your manifest often must be the first entry in the archive.
This question already has answers here:
How to create a Jar file in Netbeans
(4 answers)
Closed 9 years ago.
I created a java project using netbeansIDE. Now I want to convert it into an .exe file, but I need to convert the java project into a .jar file first, since java project can't be compiled into a .exe file directly it can be only be converted to exe from jar file. So how shall I convert java project into a .jar file. Please answer in detail since I am a beginer in java programing.
Thank You.
If you are using Netbeans IDE then you can easily build a jar file of your project.
Just go to Run in the Menu above and select clean and build.
Now goto to you project folder, find Dist folder inside it and there you have your .jar file.
This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 9 years ago.
There is probably a duplicate or a simple question but I would just like to do this so I can add my game to a .zip directory so it takes up less space.
I'm not used to working with JavaScript, but I am really good in Java. And when I do so, I use Launch4j. It is a really easy to use program, and it is made in Java. Here is where to find it:
http://sourceforge.net/projects/launch4j/files/launch4j-3/3.1.0-beta2/launch4j-3.1.0-beta2-win32.exe/download
Now when using Launch4J, what you do is open it, and there is going to be a bunch of Text Fields. The first one is Output File. Here you select where you want the EXE to go. Next one is Jar. Here you select what Jar you want to turn into windows executable. Now what you want to do is go up to the tabs, and go to where it says JRE, and there, under min JRE, i would say put 1.5.0 or 1.6.0. Now go back to basic. If you want an icon, and not just the regular windows one, make a PNG file of the icon. (note you will have to add one to the Java code if you want it in the program, this is just for the desktop icon.) then once you have your PNG, go and convert it to an ICO file. I suggest using http://www.convertico.com. Now you get that ICO file in the Icon button. Now you are done. click the gear icon at the top, and it will ask for you to make a new txt file. just save it wherever it really doesnt matter. you can delete it. Now you have it! Look where you put the EXE file and it should be there! Hope this helped you!
This question already has answers here:
How to make a JAR file that includes DLL files?
(2 answers)
Closed 9 years ago.
I have a third party library that comes with .dll files that I need in order to run my java jar file. How can I include them in my jar file when I deploy my application? (I am using JSmooth to create an exe file - if that helps anything)
NOTE: I have looked at this stackoverflow question, but there's only one answer there, and I don't think it will work for me.
Thanks so much!
this has come up before. the short answer is that you cant - the dll has to be accessible to the underline OS and so cannot be inside the jar.
it can, however, be unpacked from within the jar to somewhere in the PATH before you call loadLobrary ....
look here : How to make a JAR file that includes DLL files?