I'm working under a java desktop application project. I completed my java project using eclipse and it has many packages and class files in separate packages. My main class is Mainframe. My problem is I have to install this project into another computer, how can I convert my project to installation file?
As the Help page says:
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 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.
Optionally, you can also create an ANT script to quickly regenerate a previously created runnable JAR file.
If you want to export it in a manner that allows another user to import and edit it, than export it as an archive:
You can use Launch4j (http://launch4j.sourceforge.net/) to be able to create executable files (.exe) from Java projects.
Related
I exported my project using the Export as Runnable Jar option in Eclipse, which worked perfectly fine originally.
However, I now have a splash image that I need to include in the manifest for the Runnable jar, which cannot be specified when exporting as a Runnable Jar.
So, I tried to do Export as a Jar and just set the manifest manually through there. It allows me to set the manifest, but another problem arises. It won't let me extract/package the required libraries like the Runnable Jar export allowed me to do.
If someone could tell me a method where I could export the project as a runnable jar with a custom manifest and the extraction of required libraries into the jar, I would highly appreciate it.
Thanks to howlger for helping me find the solution!
I first acted as if I wanted to create a runnable jar by right clicking my project, clicking export, and clicking runnable jar.
Then, I exported it as a runnable jar but also checked to get the ant build script to my desktop.
In the generated build.xml file, I edited it using a text editor program and added the SplashScreen-Image attribute
Now, to use this new build script to export the project, right-click the project file, go to properties, go to builders, click New..., and go to Ant Builder
Choose the location of the modified build file you exported for the Buildfile, and choose the project folder as the base directory for the Base Directory.
And that's how you can modify the manifest of a runnable jar file.
Update:
To run the necessary ant configuration, click the arrow next to the button to the right of the green play button that looks like this:
Once you click the arrow, click "External Tools Configurations..."
Add the Ant Build configuration previously made, or if it doesn't show up, add it using the previous steps.
Once this is done, click close and click on the aforementioned play button with the red toolbox next to it to build it.
Another approach is to:
Export your runnable jar in Eclipse
Create a file (addToManifest.txt) with your manifest permissions inside. For example:
Permissions: all-permissions
update the manifest using the jar command:
jar ufm dist\myApp.jar addToManifest.txt
Then sign your jar with the standard jarsigner
jarsigner -keystore yourkeystore.jks myApp.jar yourAlias
I'm learning Hadoop under VMware now.(win7, 64) Due to some reason, I can't convert a .java file to .jar file under virtual machine, so I tried to create .jar file under Eclipse.
I'm currently using Eclipse MARS(4.5.1). I need to download something about fat jar, but I can't find it online.
My colleague copied his Eclipse software to me. It is already installed, so I copied the whole package. It is Eclipse Kepler. So I am running two Eclipse software on my computer now. will this cause some problem? (I saved projects seperately)
I can do the convert .jar file thing correctly on Eclipse Kepler now. But I still want to use MARS and delete the extra Eclipse.
thank you !
What you're looking for is the "Fat JAR" eclipse plugin.
Fat jar is a jar which contains all the classes used by the project including their referenced dependencies.
The plugin can enable the creation of such a jar.
In your case, however, Eclipse "Mars" & Eclipse "Kepler" include this functionality. The trick is to get to it...
Here's what you do in order to export a Fat JAR:
Right-click on the required Project and select "Export..." --> "Runnable JAR file".
Select the option which extracts libraries and specify the destination JAR file.
Launch configuration is used to execute this JAR with a predefined "Main" class (this is the "Runnable" part...) using "java -jar file.jar".
If you don't plan to - it won't matter.
(Optional) You can also "Save as ANT script" which, well..., generates XML ant script as well.
select project
select Export
Expand the Java node and select JAR file. Click Next
In the JAR File Specification page, select the resources that you want to export in the Select the resources to export field
.
Select the appropriate checkbox to specify whether you want to Export generated class files and resources or Export Java source
or go to http://www.codejava.net/ides/eclipse/how-to-create-jar-file-in-eclipse
I am trying to deploy an FXML project as a runnable jar and I am using an external library controlsfx-8.20.7.jar for some custom Dialog Boxes and the application works fine in Eclipse but once I export it as a runnable jar all the operations that involve invoking some methods in the controlsfx jar gives me an error java.lang.ClassNotFoundException
You probably didnt extracted all the required libraries, try right click on your project go to EXPORT -> Runnable JAR file-> choose export destination and in Library holding check "Package required libraries into generated JAR" after that finish and you will be able to run it without exceptions
How can I create a runtime package of some sort -- an all-in-one jar with the Main class specified, a Mac .app, or similar -- from an Eclipse Java project? I would like to get all the required jars and so forth without having to make the batch file myself.
Right-click on your project in Eclipse, and select Export. Select Java->Runnable JAR File.
You can then select a particular Eclipse Launch Configuration on which to base the export (i.e. the main class and the classpath used to run it), whether to extract or package the required libraries, and whether to create an ANT script (so you could build the JAR file outside of Eclipse).
I'm trying to export a program in Eclipse to a jar file.
In my project I have added some pictures and PDF:s. When I'm exporting to jar file, it seems that only the main has been compiled and exported.
My will is to export everything to a jar file if it's possible, because then I want to convert it to an extraditable file, like .exe-file.
But how?
No need for external plugins. In the Export JAR dialog, make sure you select all the necessary resources you want to export. By default, there should be no problem exporting other resource files as well (pictures, configuration files, etc...), see screenshot below.
Go to file->export->JAR file, there you may select "Export generated class files and sources" and make sure that your project is selected, and all folder under there are also! Good luck!
FatJar can help you in this case.
In addition to the"Export as Jar" function which is included to Eclipse the Plug-In bundles all dependent JARs together into one executable jar.
The Plug-In adds the Entry "Build Fat Jar" to the Context-Menu of Java-projects
This is useful if your final exported jar includes other external jars.
If you have Ganymede, the Export Jar dialog is enough to export your resources from your project.
After Ganymede, you have:
One more option is WinRun4J. There is an Eclipse Plugin for WinRun4J that allows you to export your application as a single executable with necessary jars/classes embedded.
(full disclosure: I work on this project)