This question already has answers here:
How can I convert my Java program to an .exe file?
(16 answers)
Closed 7 years ago.
I am new for java. As a first step, I made a simple calculator in NetBeans.
I wanted to make it an executable software and to run it just by double clicking it as on visual basic.
Please tell me if you know a method to do that.
I don't know your IDE but you need to export an as executable jar file. Then you can run that.
In Eclipse:
File > Export > Runnable Jar File > Choose your path > Click export
Right click on the project -> Clean and build
You can find the runnable jar in your project folder > dist (newly created folder)
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 an answer here:
How to export an Eclipse Project with External Jar dependencies?
(1 answer)
Closed 8 years ago.
I have developed a program that includes external jars also. Now I need to convert this program to a runnable jar (It has main method) and place it another location.
But how to include the external dependencies along with this conversion . I dont want other to download the external jars again and again.
Regards,
Siva
Right click on your project then go to Export -> Java -> Runnable JAR File and there select Package Required libraries into generated JAR radio box
This question already has answers here:
How to make an executable JAR file?
(5 answers)
Closed 8 years ago.
I have written a simple little program that opens a JFrame window every time you click a button. Although each time I want to run it I have to go into my IDE(NetBeans) and run it from there. Would I be able to make a .jar thing and it will run like that? How do you make it executable. Should I use a batch or bash file to run it?
In Netbeans you can right click on your project in the Project Explorer and then select clean and build.
After that you can find the .jar under dist, which is located in your project folder.
You're looking to make a jar file. If you're on windows/x whatever graphical interface, you simply run it like any other executable. If not then you can run it from the command line like any other program.
To make a jar from the command line as per the Oracle documentation http://docs.oracle.com/javase/tutorial/deployment/jar/build.html:
jar cf jar-file-name input-file(s)
NetBeans also has an interface to turn your project into a .jar if I recall correctly.
Edit: Yes it does have an interface. A quick search of the site yields:
How to create a Jar file in Netbeans
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:
Closed 10 years ago.
Possible Duplicate:
Corrupt jar file
I made a game in Eclipse and packaged all the class files in test.jar. When I attempt to run it, it gives me the error:
Error: invalid or corrupted jar file.
I opened the .jar file using Winrar, and everything is in there.
I have looked for a similar question on Stack OverFlow, but didn't find any. Can you explain to me how I can solve this error?
FOR EVERYONE WITH THIS PROBLEM ,SOLUTION:
Go to file, export, export as a Runnable Jar, Select your main class, finish.
If you want to run your program in cmd, create a new textfile, and type java -jar project.jar with project = name of your program.
Save this as Run.bat
then open the Run.bat, it will automatically open project.jar
Thats it, it worked for me!
How you place your classes to tar.jar? A valid jar file must follow some rules it requires. You'd best generate them by your Eclipse tools. click "export" -> "jar" and select the right entry of your game. Good Luck.