Creating java executable in eclipse
Go to file->export->runnable jar and select the class which contains the main
method.
Setting .JAR File Association
Normally, the installation program for the Java 2 Runtime Environment will register a default file association so that .JAR files will execute with 'JAVAW -JAR' by double-clicking any .JAR file. If this does not happen, or it somehow gets changed, then manually setting the association for *.JAR files may be needed.
- Open the Windows Explorer, from the Tools select 'Folder Options...'
- Click the File Types tab, scroll down and select JAR File type.
- Press the Advanced button.
- In the Edit File Type dialog box, select open in Actions box and click Edit...
- Press the Browse button and navigate to the location the Java interpreter javaw.exe.
- In the Application used to perform action field, needs to display something similar to
"C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe" -jar "%1" %*
then press the OK buttons until all the dialogs are closed.
Now you should be able to launch any *.JAR
program by double-clicking it.
This step by step guid was taken from: http://windowstipoftheday.blogspot.com/2005/10/setting-jar-file-association.html
Create executable Jar file under Eclipse
To create a new runnable JAR file in the workbench:
- From the menu bar's File menu, select Export.
- Expand the Java node and select Runnable JAR file. Click Next.
- In the 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.
- Optionally, you can also create an ANT script to quickly regenerate
a previously created runnable JAR file.
Create a java executable with Eclipse
You need to create an executable JAR file. Steps will follow shortly.
Right click on the project and select JAR file under Export.
Enter the path where you want it to be saved. The example here is of Windows. Change according to your platform.
Click Next.
Edit the Main Class field by browsing and selecting the location of your class that contains the main
method.
Run it
To run the JAR file, open up a shell or command prompt and execute the following command:
java -jar path/to/test.jar
How to generate executable of java project in eclipse
I recommend launch4j to create executables from JAR files.
Related Topics
Variable Column Names Using Prepared Statements
How to Instantiate an Abstract Class
Connection Pooling Options With Jdbc: Dbcp VS C3P0
Hibernate: Hbm2Ddl.Auto=Update in Production
How to Cast a List of Supertypes to a List of Subtypes
How to Mock a Final Class With Mockito
Match Multiline Text Using Regular Expression
How to Parse Dates in Multiple Formats Using Simpledateformat
Why Do I Get "Exception; Must Be Caught or Declared to Be Thrown" When I Try to Compile My Java Code
Multiple Row Selection in Jtable
Arval SQLexception: Fatal: Sorry, Too Many Clients Already in Postgres
Cross-Platform Way to Open a File Using Java 1.5
How to Use Chef to Update-Alternatives for Java Using Execute
Why Stringbuilder Stops Adding Elements After Using the Null Character
Eclipse Release Heap Back to System