I've made a program to help me out with some stuff, but every time I need it, I open Eclipse and Run it.
Is it possible to create an executable file so I won't need to open Eclipse every time?
The commands I use is basically System.out.println() and Scanner to read what I type.
Right-click on project.
Export as runnable jar.
File -> Export -> Java -> Runnable JAR File
You'll have to choose the main class that you want it to run. This will allow you to double-click on the JAR, and have it run that main.
You can File > Export > JAR file to export your project as a jar and put the java command to run the jar on a windows batch file. Alternatively you can File > Export > Runnable JAR file
You can either create an executable jar file (using eclipse, or a build tool like "ant" or "maven") or you can also create a "real" Windows-executable file (which you can also give to customers/friends).
I am using JSmooth a lot ( http://jsmooth.sourceforge.net/ ) - this builds a wrapper around your jar-files and can help the user with downloading and installing an appropriate java virtual machine version.
Probably the executable jar (see answer of Serplat) file is what you need :)
Related
I have a project with 3 java files:
Title_Screen .java
Game_Screen .java
Game_Code .java
Game_Screen and Game_Code use OpenGL, and Title_Screen opens Game_Code which opens Game_Screen. In eclipse, the program works perfectly, but when I try to export it as a runnable jar file, no matter what I do, it always just exports Title_Screen.java. What am I doing wrong, and what steps do I have to take to export all three java files in one .jar file?
Edit: It seems to only happen to my program, perhaps it's something to do with the OpenGL libraries?
Edit 2: I removed the libraries from my program, same results as exporting it to a jar file. My actual problem is that I can't put in the libraries.
Edit 3: Problem resolved! All I had to do was use jarsplice to create my runnable jar, not Eclipse. Tutorial I used: https://www.youtube.com/watch?v=YqGUk84BmlQ
You can use the following command to build the jar and specify the main class entry point (Main).
jar cfe output.jar Main src/Repository/* src/util/*.class
you can write multiple files when creating the jar
jar cf Output.jar src/util/Main.class src/util/SubMain.class src/Repository/*
Or from eclipse
Put all your files in a folder in your Eclipse project and then:
1.Right click in your folder
2.Export
3.Java -> Runnable JAR File
What steps are you following to export it as runnable jar?
Are you able to run the jar file successfully?
Steps to export Runnable jar is :
Right click on project and select "Export" option.
Provide the destination path where the jar file needs to be store.
Export
I have a project in eclipse which uses part of another java project for changing some variables. I need to create an executable file from my project but all instructions that I try doesn't work.
I created a runnable jar file by exporting my project but the jar file doesn't run. Then I used the launch4j to create an ".exe" file from the jar file but when I click one the .exe file instead of running, it unzips to a folder.
just in case if it is an important point, I am using mac os.
In Eclipse;
Click Next and give a destination
beginner
I've searched the entire internet on how to convert java program to exe but all I see is "convert .jar to exe". there is no jar file in my program. My program is coded in java in eclipse IDE how do I convert this program to an independent application. an executable file. it has three classes. one of them is a main class. I tried using JSmooth but I had no idea what I was even doing.
Desktop/command line Java programs are compiled into .jar files. You can make a "runnable jar" that will launch your program when the user double-clicks it.
Here's how to create a runnable jar in Eclipse:
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Ftasks%2Ftasks-37.htm
From the menu bar's File menu, select Export.
Expand the Java node and select Runnable JAR file. Click Next.
In the Opens the Runnable JAR export wizard Runnable JAR File Specification page, select a 'Java Application' launch configuration to use to create a runnable JAR.
In the Export destination field, either type or click Browse to select a location for the JAR file.
Select an appropriate library handling strategy.
As far as converting your compiled Java .jar into a Windows .exe, you might consider using Launch4j.
Jsmooth wraps you jar into an exe, but its old and outdated. I recommend Launch4J, its easy to use and works well.
http://launch4j.sourceforge.net
I had a question regarding JDeveloper's methodology for generating executable jar files.
I have tried several tutorials for building JAR files and finally found one that generates an executable jar file that i can run on a Linux system. Here is a link to it http://idlebrains.org/tutorials/java-tutorials/generating-executable-jar-file-third-party-library/
However, the building of the 5 MB file takes, on average, 1 hour and 40 min. I looked at the JAR file once it was built and it seems that all the libraries that i had included in my build were somehow decomposed into their component code. What I mean is that the libraries that i included in my build don't appear as .JAR files inside the executable JAR.
I have been looking into why it would take so long and why JDeveloper would not simply add the dependent JAR files in the executable JAR as simply JAR files. However I have not had much luck.
Any insight would be greatly appreciated.
Eclipse can build jar files which you can then execute.
Right click on project -> export -> Java -> Runnable Jar File -> Select the Launch Configuration Corresponding to your Project -> Package Required Libraries in Generated JAR -> Select Export Destination -> Finish.
It should only take a couple minutes, tops.
Then, go to the JAR file, right click on it -> properties -> permissions -> allow executing file as program.
Now you should be able to run the JAR file by opening it with Java. If you wish to see console logs, open up the terminal and run "Java -jar location/to/jar/file.jar". Note that this method doesn't even require for the JAR file to be marked as executable.
I want to run my java project which i've built using Eclipse IDE. Now my goal is to create a batch file which will execute my project with one click. i referred question , but didn't get any idea. Please give me a solution. Thanks in advance.
Because you are working in eclipse, this makes things easier. First, export the whole program as a executable jar. You can do this by going to Files>Export and then in the pop up go to Java>Runnable Jar. Then follow the steps required to make it. Next you make a .bat file and write the following code.
start javaw -jar NameOfJar.jar
Make sure that you put the file in the same directory as your jar. Now you should be able and click on the .bat and execute the program!
1.Open Notepad & write
#echo off
javac YOUR_JAVA_FILENAME.java
java YOUR_JAVA_FILENAME
2.Save-As executeJavaProgram.bat
Make sure that YOUR_JAVA_FILENAME.java resides with your batch file and java path is set in environment variable.
3 . Double click on batch file.
Follow this tutorial to create a jar file of your eclipse project.
After doing it create a batch file in the same folder where you exported the jar with the command: java -jar yourjar.jar
Create jar file using eclipse i.e right click on your project select export jar file then provide file name to store your jar file. In this file eclipse will keep all .class file only and in META-INF folder main class definition if your are creating executable jar file.