How to create runnable JAR in Eclipse

I have a project in Eclipse with many classes.
Whenever I try to create a runnable JAR, the JAR file created always contains all the classes of the project, regardless whether they are really used or not.
Is it possible to create a runnable JAR in Eclipse, excluding the classes of the project which are not strictly necessary for a given launch configuration?

krige wrote:
I have a project in Eclipse with many classes.My condolences on using a build system that apparently has grabbed you by the short & curlies. That can be painful.
Note that:
1) Eclipse can use Ant style build.xml files for controlling most aspects of a build (that are worth mentioning).
2) We provide no support for Eclipse on these groups, but since Ant typically defers to a core set of tools in the SDK, you can usually get away with asking an Ant related question.

Similar Messages

  • How to create executable jar in eclipse using linking in compiler

    Hi,
    I have a project in Eclipse. I wrote already an ant build file for creating an executable jar which includes all project files.
    Now I want to create a second executable jar which is a subset of the project (a limited number of classes are necessary).
    I have a main class and I was looking for a way to generate a jar file which includes the main class and all the depending classes.
    Is there a way to do it? With ant or with another tool?
    Is it possible to compile a project given a main class, and include all depending classes?
    Regards,
    Biebel
    Edited by: biebel1975 on Jan 7, 2009 10:21 AM

    biebel1975 wrote:
    Some more information:
    When I compile all the classes, the jar file is +/- 3.5Mb inclusive the server side logic.
    The subproject I want to build, should be less then 1Mb (Only some screens and beans, no business logic ((only +/- 10% of the projects code) )).
    My question is: How can I create a executable jar with only the necessary class files which depends on the main class. (Linked with the imports).
    Is there a tool to do that? Can it be done with an ANT script? If so, how does the script looks?
    What are you talking about?
    You already said that you are using Ant.
    Ant uses script files.
    Since you have one with X items in it and you want something new with X-Y items in it the obviously it would make sense to construct an ant script that does less than the other ant script.
    The following provides a huge amount of information about Ant.
    [http://ant.apache.org/resources.html]
    Other than that no one can tell you want your Ant script will look like except that it will do less than the one that you already have.

  • Runnable JAR in Eclipse

    Hi,
    I'm trying to make a runnable JAR in Eclipse, but I don't know how to limit which libraries or other source codes to be included inside. Does anyone know how to do this? The JAR I'm making is 13.6 MB, much bigger than I think it should be.
    Thanks.

    You can create a runnable jar file only when u have a public class with main method as a entry point of java Application.Always create runnable jar file when u r using GUI in ur java application.
    Steps which r required in Eclipse for creating runnable jar file as herein after provided
    1-Right click on your project and select export option.A export window will get pop-up.
    2-Select jar file option from the poped-up window which will be in java option of window.
    3-After Clicking JarFile option a new window will get pop-up.
    4-Select the export destination for ur jar file and click next.
    5-After clicking the next a new screen you will see, click on next button again.
    6-Now u will see a new screen which has a field name as "Main Class" browse for your main class of appliaction.main class is once which has main method.
    7-Now select finish.
    U hav done..
    now double click on your created jar n u will see the output.....
    if u hav any other problem...than let me know
    Regards,
    Ashvani Kumar

  • Runnable JAR from Eclipse with DLL

    Hi,
    Is it possible to export a runnable jar from Eclipse that includes and uses a dll?
    My simple application uses an 'external' API - JIntelliType - a jar file and a dll belongs to it.
    I can run the project fine from Eclipse, but I can't export it to runnable jar. I am a bit lost among classpath, path, build path, native library location, referenced library,..
    But maybe it doesn't matter because after trying to look this question up on the net, I am not sure if it is possible to do it with Eclipse (not without additional plugin at least).
    Could somebody please help me with this?
    Thank you in advance!
    lemonboston

    Your question is that of deployment. In Eclipse you setup your development environment to include native binaries in the projects working directory. As soon as you leave Eclipse you do not have its facilities anymore and you need to make do with what the JDK has to offer you.So your real question is: I have a jar and a DLL, the jar depends on the DLL. How do I run the application such that the DLL can be loaded by it?
    The answer is: you can provide through a system property (java.library.path) which directory Java (and ultimately the operating system) should scan for native binaries, or you can simply put the DLL in the same directory as the jar. The current working directory (the directory where Java is invoked) is always on the binary search pat of the operating system.
    The documentation for the java tool is here:
    http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html
    To pass a system property as a parameter you would do something like:
    java -Djava.library.path=path/to/libs -jar yourjar.jar

  • Creating Runnable Jar

    Hi,
    I made a simple program and I want to create a runnable jar.. I have a config file, How can I exclude the config file when I create runnable jar? so, i can be edited..

    Here is my heirarchy The hierarchy inside the JAR file is the only hierarchy of interest here.
    I will create a runnable jar, but how can I extract the config.properties so its editable when I run the runnable jar.Class.getResource() and friends.

  • How to create a .jar file in wlcs3.1

    hello friends,
    hi friends, im working on weblogic commerce server3.1 . i dont know how to create a .jar file in weblogic commerce server3.1. can any one knows send email to me.
    thanks.
    hari

    $JDK_HOME/bin/jar (%JDK_HOME%\bin\jar) shows you the syntax
    where JDK_HOME is your jdk installation directory.
    Kumar
    hari wrote:
    hello friends,
    hi friends, im working on weblogic commerce server3.1 . i dont know how to create a .jar file in weblogic commerce server3.1. can any one knows send email to me.
    thanks.
    hari

  • How to create executable jar files??

    how to create executable jar files??
    thx :)

    Using JAR Files to Deploy
    http://developer.java.sun.com/developer/onlineTraining/Programming/BasicJava2/jar.html#jar

  • How to create a JAR

    Hi
    I'm very new to Java. I have a private project to do a little admin application for bulk changes to my itunes library via their COM API. Previously I used several javascripts to do this so I don't expect a lot of work to adapt them to Java. I use eclipse and have downloaded com4j (https://com4j.dev.java.net/servlets/ProjectDocumentList) to create wrappers to the COM-objects in iTunes. the quick intro to com4j say that the wrappers are created by the tlbimp.jar. I know that JAR is a a java archive created by jdk using jar.exe but I can't get out a tlbimp.jar file how much i try. If I do something like this
    jar -cvf tlbimp.jar *
    Does that make sense? What prerequisites are important? Does jar.exe have to be in som path variable in windows? Should I be in the folder where the classes are or one level up? Anything else
    Edited by: 802710 on 2010-okt-15 03:16

    802710 wrote:
    Hi
    I'm very new to Java. I have a private project to do a little admin application for bulk changes to my itunes library via their COM API. Previously I used several javascripts to do this so I don't expect a lot of work to adapt them to Java. I use eclipse and have downloaded com4j (https://com4j.dev.java.net/servlets/ProjectDocumentList) to create wrappers to the COM-objects in iTunes. the quick intro to com4j say that the wrappers are created by the tlbimp.jar. I know that JAR is a a java archive created by jdk using jar.exe but I can't get out a tlbimp.jar file how much i try. If I do something like this
    jar -cvf tlbimp.jar *
    Does that make sense? What prerequisites are important? Does jar.exe have to be in som path variable in windows? Should I be in the folder where the classes are or one level up? Anything elseIt sounds to me like the documentation is saying that Java classes in the tlbimp.jar are used to create the wrappers - you do not need to create that jar. I bet if you look at the zip file you downloaded, you will find tlbimp.jar inside the zip file. You need to extract that jar and any other jars inside the zip file and configure Eclipse to use them.

  • How to use external JARs in Eclipse

    Hello.
    I created a jar file like that:
    jar -cvf0 WarShell.jar WarShell.class
    I want to use WarShell.class in Eclipse but it not in my classpath,so I choose [Project] -> [Properties] -> Java Build Path -> Libraries -> Add External JARs and add WarShell.jar to the list.
    But when I run the program I got a Exception:NoClassDefFoundError.
    Why?How to fix it?
    Another question... Your classpath is not available in Eclipse,right?
    Thanks for your time! ^_^

    Hello.
    I created a jar file like that:
    jar -cvf0 WarShell.jar WarShell.class
    I want to use WarShell.class in Eclipse but it not in
    my classpath,so I choose [Project] -> [Properties]
    -> Java Build Path -> Libraries -> Add External JARs
    and add WarShell.jar to the list.
    But when I run the program I got a
    Exception:NoClassDefFoundError.
    Why?How to fix it?Did you run your program from Eclipse ?
    If yes, it should work (or seek for an Eclipse-specific forum.)
    But if not, keep in mind that your project settings are limited to Eclipse. You'll have to define a correct classpath for running your application.
    Another question... Your classpath is not available
    in Eclipse,right?Mine? I don't think it is available for anyone ;-P

  • Creating a JAR in Eclipse...can't access files in the JAR properly.

    Hi all! I'm a newbie at JAR creation, and am having troubles. I have a project that loads images from image files in my project. I can create the JAR and all, and it runs, but the buttons that have ImageIcons with those IO loaded images are blank. I've tried to include the images when creating the JAR, but it keeps acting like the images never existed. When I run the JAR and have the images separately included in the directory (instead of packing them up too), it won't work as well...UNLESS those images are put in my $HOME directory (Linux).
    Does anyone know how I can properly refer to the images that I'm trying to pack into the JAR from within the JAR? Or, is there a way for the JAR to understand where those images are supposed to be (redirect the focus from the $HOME directory to the JAR's directory)? Any help would be greatly appreciated! :)
    -Keith

    Hi,
    Can the user execute the program through explorer? In Windows Server 2003, the Users group does not have Read and Execute permissions to the command processor (Cmd.exe). 
    You could refer to the article below to resolve the issue:
    "Access is denied" error message when you run a batch job on a Windows Server 2003-based computer
    http://support.microsoft.com/kb/867466
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to create a .jar file for the BPEL project

    hi all,
    how can i create a .jar file for my BPEL project, i am trying to deploy the project but getting an error :
    "Error: [Error ORABPEL-10902]: compilation failed [Description]: in "C:\OraBPELPM\integration\jdev\jdev\mywork\Workspace_BPELDemo\BPEL_Report\BPEL_Report.bpel", XML parsing failed because "". [Potential fix]: n/a. "
    and when doubel cliking on this error Jdev take me to the beginning of the ".bpel" file.
    I 'm really stuck in here i am not able to deploy the process!
    Thanks,
    Rana

    Rana:
    If you haven't already, I would post this question in the BPEL forum. I would expect a much better turnaround there.
    Johnny Lee

  • How to create a jar file which is in the remote system?

    Hi,
    I have a set of files that resides in a remote system,which have to be "jar"red. I have a firewall in between. I want to create a jar file out of the files situated in the remote system.How do i go about this process.?

    Hi,
    You can't do that in a simple way. You need to have a port open in the firewall, and you need to have a server process on the remote machine.
    Kaj

  • How to create WAR file in eclipse?

    Hello everybody,
    M using eclipse.
    m facing problem to create WAR file.i dont know how to create it.
    m using -cvf command for it.
    Let me know how to create from eclipse IDE.

    You need to export a project to war file or to create a war file ?

  • How to create a Jar with only class files?

    Dear all,
    I want to create a jar file with only classes.My class files and java files are in different folders under com .
    say
    com
    in com there are two folders
    folder 1 -- subfolder 1
    folder 2 -- subfolder 2
    like this.
    If i want to create a jar file from com directory how should i give the jar command.Again my jar should contain only .class files.
    Any help will be appreciated
    Thanks
    lekshmi

    It doesn't work.Says "No such class or directory"
    Any other way Or is it possible to do so?Read the link I posted and create the statement to make your structure. I was thinking you were inside the com directory but if you are above it you will need something like this instead:
    jar -cf test.jar com\*.class com\subfolder1\*.class com\subfoler2\*.class
    But either way don't just copy and past this. Think about what is does so that you can make it work for you.
    Also, you might want to look into using Ant if you are going to be building this a lot.

  • How to create a Jar files

    I m New in java i want to create a jar files but i dont know how please anyone help me and answer my question thanks.

    Hi muhammadawood,
    Creating a jar file is easy. First of all, a jar file is not much more than a zip file. You can use your favorite zip program (ie. zip, WinZip, pkzip, etc) to create the jar. To do this, zip all your classes together into a zip file. Then, rename the file w/ a .jar extension. This method doesn't support a small set of features defined by jar, but it will work nonetheless.
    If you are using the Forte IDE, it has the ability to create a jar from a menu.
    Regards,
    Nick G.

Maybe you are looking for

  • Multiple Desktops (When you don't want them...)

    I travel quite a bit and when I am at home I use my MacBook Air with my TV over TB to HDMI...everything with the Air was working fine until this morning...now I have two complete desktops (using different desktop images) on my Air...not sure what hap

  • Yosemite 2012 Macbook Pro grpahics problem

    Hi, I guess this problem is directed at Apple rather than the users of this forum. My trusty 2012 Macbook Pro has become a nightmare since upgrading to Yosemite.  I run my own business and use my machine primarily for Autocad, Photoshop, Indesign and

  • Problem with printing envelopes

    I have an HP Laser Jet P2035.  It gives me trouble printing envelopes for work.  I put the envelope on the tray, press the print button and with almost every envelope, it prints information about the priniter, and THEN it prints an envelope.  It's wa

  • Correlatio​n between two arrays

    hello, please i need help in labview. i have collected data in stabilometer and i determined the area and circumference of XY graph for 30 staudents before and after carrying a backpack, so I want to enter the values of the area for the 30 students b

  • Can't burn project to dvd successfully

    I have PSE 12 both organizer and Premiere. I've completed a movie project after first working up a slide show in Organizer but when I tried to burn my dvd the program did not recognize my burner (which is LG's HL-DT-ST GH24NS50 SC SI) so I burned to