Till now, I have been using Netbeans IDE for Java Applications. To distribute applications made in Netbeans, I just click on clean and build and it packs the application in .jar file which resides in a dist directory.
Now I have made a java project in Eclipse. Is Eclipse has any functionality similar to clean and build functionality of Netbeans by which we can pack java applications to distribute them.
You can right-click the project, select Export and choose Java, then JAR as the format.
File -> Export...
And choose Java -> JAR File. You will get a wizard to export any of your projects
Yes it has a clean and build functionality.
clean which clean all the developed a classes from the specified location
build which builds the class files at the same specified location respectively.
To distribute a project as a jar then you have to right click on the project and select export and in that select as jar.
Eclipse has a function to export the whole thing as a exetutable jar. It is under file>export.
Related
When I create a project in Eclipse, I have to manually export the Ant build files to be able to build from command line easily.
Is there any way to make Eclipse generate the Ant build files when creating the project without further interaction?
With standard Eclipse it's possible to generate ant build files (Right click on the project -> Export -> Ant build file) but you need external plugins to generate them automatically (Web Tools Platform if I recall correctly).
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 have Tapjoy sources sources, which have such sructure: Tapjoy/src/com/tapjoy/*.class
It must be compiled with Android API Level 9 and higher.
My project is in version Android API Level 8.
So I need to make from sources of Tapjoy -> tapjoy.jar file and include it to my main project.
How can I make .jar file properly with command line or from eclipse?
In Eclipse IDE, it's very easy to create a JAR file.
Just right click on your package > Export > Java > JAR File (and follow the wizard!)
Or from command line
jar cvf tapjoy.jar Tapjoy.class
both are possible
you can also use ant or maven for this kind of functionality.
check for the jar tool for commandline approach!
check eclipse ant build for eclipse approach and check the ant jar task for ant approach
In Netbeans IDE, you can easy create own jar library,
Projects on Right click -> Clean and build
Thats it. You can use it now your "Project Location"/dist/MyApplication.jar
All you need to do create new project and import your jar file How to import Jar File ?
I've downloaded sources of one application using Subversion repository, but it turned out, that those sources were not composed to a NetBeans project. It was said in the manual, that I can build it using Apache Ant. I know, that NetBeans supports Ant by default. So here is the question - how can I tell NetBeans to run it's Ant on a specified build.xml?
File -> New Project
Then in Categories pick Java and then in Projects select Java Free-Form Project and hit Next. After that you will configure the project by selecting the location of the project the and build.xml and then associate targets in the build.xml with actions in the IDE.
The site I'm working on now is made up of several java projects and a main web project A which references them. The IDE I'm using is Eclipse Helios.
What I'm trying to accomplish is adding a new project B to the stack. The project is also referenced by the main one, but is in itself a Web Project. When I add B to the Deployment Assembly of A, when publishing, Eclipse automatically packages it as a war and deploys it to the server's WEB-INF/lib.
I want it to be deployed as a jar, but also keep the project's web nature, as it has some features (and tests) that are run on it. I have ant tasks in place for building a jar out of B, but I don't know how to use them in Eclipse. Also, I'm not sure if it's possible to make Eclipse deploy a jar out of a web project.
I can add the jar manually (as an archive from the workspace), but that would mean that whenever someone cleans all projects, the jar for B would get deleted and not generated, as the build only compiles the classes and the deploy packages them into the war.
P.S. I know the design is poor, but changing it is out of the question as I don't have the authority :).
I found the following solution that works for me on Eclipse Luna
Project B "Project Facets" : select "Utility Module" instead of "Static Web Module" or "Dynamic Web Module"
Project A "Deployment Assembly" : remove "B" and add it another time.
=> The "Deploy Path" of B is now B.jar
The easiest way is: File -> Export... -> Java -> Jar File
To use ant: open project properties, the go to Builders, Click new, selec Ant Builder, etc.
You can do something like this:
Write a shell/batch script that
calls ANT script of project B which creates a JAR file.
and then, it calls ANT script of project A.
Update ANT script of project A, add a copy task. This file copy task will use relative path to copy the JAR file created in step#1 to project A's WEB-INF/lib directory.
In Eclipse, go to External Tool > External Tools Configuration > Program > New Progam and add this Shell/Batch script to it.
Whenever you want to build. Run this external tool from menu.This will ensure
Your build always has the latest of Project B
ANT tasks will stay small.
Adding a Web Project in an Eclipse Deployment Assembly
I did not know any such thing, until Thorbjørn Ravn Andersen pointed this out in another question where I answered. As mentioned there:
What goes in the deployment is determined not by the build path but by the Deployment Assembly entry in Preferences for the dynamic web project.
But, may be, you have already tried this.
Edit#1: fixed grammar
Edit#2: added more info