Create Batch File From Eclipse Project - java

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).

Related

How to exclude referenced libraries from being exported when you export jar in VS Code for Java project (no build tool)

I have a Java Project for a JavaBean (multiple classes in a single project) with no build tools. In eclipse, I can export this project as JAR and I can select to export only the compiled classes without the referenced libraries.
In VS Code, when I select "Export JAR" from the JAVA Project tab, I am unable to remove the selection of the referenced libraries which is always copied to the output according to this config {"java.project.outputPath":"bin"}. Note that the referenced libraries are referenced using the .classpath file, not using the .vscode settings file with the section "java.project.referencedLibraries".
Is it possible to export JAR in vscode the same way we export jar in eclipse?
What is the command line to export the needed jar?
I appreciate your help.
Tarek
There is an advanced way to export Jar in VS Code. See: https://github.com/microsoft/vscode-java-dependency/wiki/Export-Your-Project-to-a-Jar#advanced-custom-export-task
You can use the glob pattern here to customize the exclude list. e.g., a new rule like !${compileOutput}/referenced.jar.

Convert Java project into Installation file

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.

jar file is not executing unless the entire project is included in system

I have created the automation script in Selenium using Java in Eclipse and have created a jar file by navigating through Export->java->Runnable JAR file-> package required libraries into generated JAR.All this has been done in System A.
I am trying to run the jar file in System B.But unless I dont include the entire project folder into System B.The jar file is not executing.
My question is ,how to run jar file without including the entire project into System B..?

how to make .jar file in Eclipse MARS

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

how to create jar file in netbeans

I want to create independent jar files in netbeans like we can do in eclipse. Normally people suggest to clean and built the project and there is a jar file created. But to run these jar file the .java files, the codes are also required. Isn't there any way to create jar files which runs independently without requiring java codes?
Thanks
set the main class in run configuration
do a clean build
go to the dist folder and you can find the jar there as a runnable one
for further information refer this Creating_an_Executable_Java_File_in_NetBeans

Categories