How to convert the java project to .exe? [duplicate] - java

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How can I convert my java program to an .exe file ?
Hello,
I coded a java project using Eclipse software. Now i need to convert that project to .exe file. I export that project and hence converted to jar file.
when i double click on it, it shows "failed to load Main-class attribute from 'path'". So unzipped it and looked into the MANIFEST. mf, there it has only version.
I also used JartoExe software and converted to exe file. It shows a cmd prompt like file but when i click it, i am just getting a flash of that window. Its not opening.
Please help me to convert the jar to exe file!!
Thanks in advance!

Take a look at this article: http://introcs.cs.princeton.edu/85application/jar/jar.html
You basically have to define what gets executed in the manifest and then if you want to your program under windows, you can either associate the jar type to java.exe or create a .bat file that starts the jar appropriately.

While exporting to jar file you need to provide the main class name, which is the entry point to your program.Once you do this, manifest file in jar will have entry for it and that will allow you to run it by double clicking on the jar.

When you choose Export from eclipse, one of the dialogs asks you what the main class is. If you specify it then when you double click on the jar it will launch the app.

Use JEXECreator 1.9.3, it is very good. It gives you two options to run your program: either using the console or the GUI

The easiest way to do so is to have a eclipse plugin "fat.jar" and add it to your eclipse
next you will get an option to build fat jar when you right click on your project.
Do restart of your eclipse after installing fat jar..
wow...
very easy...

http://www.ej-technologies.com/products/exe4j/overview.html
I once use this, it's good. But the free version has some kind of ads flash screen, if I'm not wrong.

Related

how to open a jar file with double click instead of terminal on Mac

I write basic java programs for fun, and unfortunately I cannot run their jar files with double clicking. However, I can open jar files through terminal with no issue. could you please explain to me the issue and how to fix it? I reordered my screen and uploaded it on YouTube if you want to see what happens when I click on a jar file:
https://www.youtube.com/watch?v=Pyh5k2w_o1s
Thanks for all your suggestions.
Try this solution:
https://stackoverflow.com/a/43881858/13257777
by script let use:
java -jar path_to_Lab15.jar
Downloading a Java Runtime Environment can do the trick.
For future projects you may want to checkout Launch4j. It is a tool to convert your runnable .jar file to an .exe.

Export Java as Jar application

i have a java project where i am accepting input from user and displaying output in console. I want to create a jar file so that other users can also run and use it. Can someone help me out with the steps. I am exporting jar file and running it but getting error " Could not find or load main class" while running.
If you use Netbean, it can build the jar file for you automatically. Just set your main class then click on clean and build.
Are you doing it through eclipse?
If yes, then follow below.
Make sure while exporting a jar to select an option under java as Runnable Jar file. Press next
Make sure you select Launch configuration, the one by which you run the project contains main method.
Hope it helps.

How can you make a Java app executable? [duplicate]

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

Creating a .exe for a java project

I've developped a game during a Game Jam and I'd like to create an executable to distribute it to the other team members.
The game uses the slick2d and lwjgl library. I've tried to use JExePack, but the .exe file I get isn't runnable, I get an error while launching it.
Even the jar file gets me errors.
I'm only able to launch the game on the IDE. When I launch it with the command line : java -jar "game.jar", it obviously tells me that there's missing libraries, even if I indicate the path to the lib folder.
Is there an easy way to create an executable ?
Thanks in advance.
I think using a jar was a good idea.
You need to add every required jar in the classpath one-by-one for the jar to run properly.
Launch4J (http://launch4j.sourceforge.net/) is my favorite tool for that. You can just export an executable jar from your IDE and create an exe out of it. Creating an executable jar in Eclipse gives you the option to include all required libraries in it, which saves you from adding them manually when create the exe file. The minimal settings you need are:
Input (your executable jar)
Output (the .exe you want to create)
Minimum Java version (i.e. 1.6.0)
Thats it (as far as I remember)
If you want the exe you can use exe4j, it's a very useful tool, but i think using jars is better since you can run them on every platform. Anyway, when you export the jar, check on your ide's preferences if it automatically imports the libs. (for example, on eclipse you can pack the required libs into the exported jar)
You can use Luncher4j to create an exe file and convert the jar libraries to dll files.

Can't open a .jar file on my mac

I'm trying to download jsoup on my mac (Mountain Lion). I've downloaded the jsoup.jar file and installed the last java 7 from the site. But here is the problem, when I double click the .jar file it tells to me:
The Java JAR file “jsoup-1.7.2.jar” could not be launched. Check the
console.
I can't find even the console! Someone can help me? I read a lot of answers about this topic, but they all talk about Java 6 and it has different settings that can't find.
EDIT
i also tried from the terminal with this command:
java -jar /Users/Ben/Downloads/jsoup-1.7.2.jar
but it tells me:
Failed to load Main-Class manifest attribute from
/Users/Ben/Downloads/jsoup-1.7.2.jar
The JSoup JAR is not executable, so you are not going to be able to 'run' it in any of the ways you described. You are supposed to include it in your project classpath and use classes from it to do your parsing (after importing them of course).
You might want to refer to the JSoup Guide for examples on using the library.
I guess you are trying to run the jsoup library as a standalone application assuming it to be an executable jar. All indicates that the jar file you are using is NOT an executable jar hence it wont work.
jsoup.jar is supposed to be used as a java library and you will need to write java code to be able to use the HTML parsing capabilities.
If you are using an IDE like IntelliJ, you can open the module settings for a particular project and select Libraries. There'll be an option to add a particular external library from the Maven repository after which you can download the JAR and include it in your project's dependencies.

Categories

Resources