Executable jar - question

I build an executable jar or exe and I want to run this program on a system(win 2000), where there is no jdk installed. Is there any possibility to built my program in such way, so that this program would run on this system?

Yes, try google to find the many many ways this can be done
http://www.google.co.uk/search?q=executable+java

Similar Messages

  • A few questions about executable Jar files

    Hi,
    I have to make an a tutorial system and was going to make it using applets embedded in webpages. This approach causes certain limitations so decided to make it using JPanels that open up as windows on the users computer.
    I intend on compressing all the files (java, images, sound etc) within a Jar file and would like a few questions answering.
    1. How would I make an executable Jar file that when clicked on will load the program on the users computer. Is there some software to do it for me or do I have to do it from the command prompt?
    2. Is using a Jar file the best approach or is there a better way to get my java program to run on other peoples pc's
    3. If I create an executable Jar file on windows xp, will it run on a Linux machine?
    Cheers

    1. How would I make an executable Jar file that when clicked on will load the program on the users computer. Is there some software to do it for me or do I have to do it from the command prompt?The SDK contains all the tools you need. Use the jar command. To make your jar executable, include a manifest file that references your main class.
    2. Is using a Jar file the best approach or is there a better way to get my java program to run on other peoples pc'sA jar will work just fine.
    3. If I create an executable Jar file on windows xp, will it run on a Linux machine?Yes.

  • Question about Executable JAR Files

    Is it possible to make an executable JAR file that has all of the *.class files, all of the *.jar archives used, etc. packaged into one file that doesn't need these external files within the same directory? I've been having a ton of trouble finding the answer to this. (If it's blatantly obvious, please forgive me.)

    Hello,
    I went through the same thing recently. Here is a piece of the build file I use:
    <project name="MyProj" basedir="." default="main">
        <property name="src.dir"     value="src"/>
        <property name="build.dir"   value="build"/>
        <property name="classes.dir" value="${build.dir}/classes"/>
        <property name="jar.dir"     value="${build.dir}/jar"/>
        <property name="main-class"  value="MyProj.Main"/>
        <property name="lib.dir"     value="lib"/>
        <path id="classpath">
            <fileset dir="${lib.dir}" includes="**/*.jar"/>
        </path>
        <target name="compile">
            <mkdir dir="${classes.dir}"/>
            <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
        </target>
        <target name="jar" depends="compile">
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
              <zipfileset src="lib/commons-codec-1.3.jar"/>
              <zipfileset src="lib/commons-fileupload-1.1.1.jar"/>
              <zipfileset src="lib/commons-httpclient-3.0.1.jar"/>
                <manifest>
                    <attribute name="Main-Class" value="${main-class}"/>
                </manifest>
            </jar>
        </target>
        <target name="main" depends="clean,run"/>
    </project>Note the <zipfileset> tags that contain the .jars.
    There are, however, many good reasons to not do this. Some were already mentioned, another is in the case of update external libraries, you might not want to rebuild your whole project, replacing a jar may be easier.
    Good luck,
    -Sam

  • Why -jar option used to install a software which is in executable jar file?

    Hi all,
    i have a query, i have a generic installer which is used to install the oracle weblogic 10.3 software in unix platform(i.e., which is in .jar extension) which is executable jar file.
    To install this software which have to use -jar option to install
    java -jar net_server<version>_generic.jar
    my question that why we use -jar option to install or to extract the software
    can any one clarify my doubt...
    thanks in advance
    abhi
    Edited by: sumanth_abhi on Jan 27, 2009 11:50 PM

    According to the Jar Guide (http://java.sun.com/j2se/1.4.2/docs/guide/jar/jarGuide.html)
    Executable Jar Files
    On Microsoft Windows systems, the Java 2 Runtime Environment's installation program will register a default association for Jar files so that double-clicking a Jar file on the desktop will automatically run it with javaw -jar. Dependent extensions bundled with the application will also be loaded automatically. This feature makes the end-user runtime environment easier to use on Microsoft Windows systems.
    The Solaris 2.6 kernel has already been extended to recognize the special "magic" number that identifies a Jar file, and to invoke java -jar on such a Jar file as if it were a native Solaris executable. A application packaged in a Jar file can thus be executed directly from the command line or by clicking an icon on the CDE desktop.
    Despite that every JAR file can be executed as a program if and only if the META-INF/Manifest.mf contains the Main-Class tag. This done through java -jar jarfile.jar
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can I add image files to a executable jar file ?

    Could you tell me how can I add image files to executable jar file ?
    package structure:
    ../com/Main.class
    ../images/..

    Please don't cross post, and read this
    http://forum.java.sun.com/thread.jsp?forum=31&thread=271751
    I've answered the question in the New To Java thread.

  • Add classpath in an executable jar file

    an executable jar file contains a manifest file with entry main-class: MyApplicationClass.
    if we double click the jar file on Windows OS, main class is loaded.
    my question is:
    if classes in he jar file use classpaths which are not default, how to add those classpaths into manifest file to tell classes to use those classpaths?
    it is similar to command line:
    java -classpath c;\mypackage; .......; MyApplicationClass

    Thanks, i will try soon.
    here is another Q.
    if i need to add tools.jar (JDK lib) as classpath in manifest file, it is as following in my PC
    d:\install\java\jdk14101\lib\tools.jar.
    but my customers install JDK in different path (should be considered as unknown), how to add it as entry Class-path for all customers?

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

  • How to pass -Hotspot or -Xingc to the jvm when using an executable Jar?

    Hi, my problem is that when i start my application with the jar-File ("Main-Class: " in the Manifest), it 's very slow.
    When i start it with
    java -hotspot -Xincgcit works fine.
    So my question is: how do I have to set these options in the Manifest of the Jar-File?
    Thanks a lot in advance.
    Michael

    So my question is: how do I have to set these options in the Manifest of the Jar-File?You don't.
    An executable jar supplies information on running it to whatever runs it. The parameters "-hotspot -Xincgc" are parameters to a specific jvm and as such belong to the jvm not the jar.
    If you want your stuff to run with that then do one of the following:
    -Provide an install that sets the computer up that way.
    -Provide a script for each OS that you support that runs it with the required options (forget the executable jar.)

  • Executable jar in jbuilder

    Hi
    i have a question for you.
    I create a jar of my application in jbuilder 2007 and when i execute with
    java -jar test.jar it's work fine.
    After i try to create an executable jar but when i execute it i have a problem.
    In a class i have error (java.lang.unsupportedclassversionerror..... major.minor version 49)
    i think that jbuilder create my executable file using jre 1.4 and does'nt use my jvm version 5.
    can you help me?

    Hi
    i have a question for you.
    I create a jar of my application in jbuilder 2007 and
    when i execute with
    java -jar test.jar it's work fine.
    After i try to create an executable jar but when i
    execute it i have a problem.
    In a class i have error
    (java.lang.unsupportedclassversionerror.....
    major.minor version 49)
    i think that jbuilder create my executable file using
    jre 1.4 and does'nt use my jvm version 5.
    can you help me?No, that means that you are trying to execute the application using a JRE that is too old. E.g. trying to execute with 1.4 but your classes requires 1.5.
    See what java -version gives
    Kaj

  • Error trying to run an executable Jar file

    Hi,
    I know a million people have asked this before. In the past 5 hours I have waded thru a dozen questions-answers-FAQs that were no help. So if anyone is willing to help a stupid person her is my problem:
    I developed a java program using the eclipse ide and it runs fine from within that ide.
    I packaged it into a Jar file, created a manifest file per the instructions.
    But when I double click on the jar file I get the following error from the Java Virtual Machine Loader;
    "Could not find main class. Program will exit."
    My Manifest file has the following text:
    Manifest-Version: 1.0
    Class-Path: swt.jar
    Main-Class: .graphicalUserInterface.AppStandAlone
    <blank line>
    the class AppStandAlone has the method "public static void main(String[] args) "
    it is in a package called "graphicalUserInterface".
    Any help anyone can give me would be greatly appreciated.

    Another 3 hours spent trying to run this java application in a Jar file.
    I identified that I did not have all class paths specified. So I tried to enter them in the "Class-Path:" line of the manifest file. But, according to the java tutorial, the syntax in a manifest file for classpaths is a space SEPARATING each path name. I have a space IN the path name and java is not understanding the paths correctly. For instance, I have a classpath c:\Progran Files\Java\etc... and java interprets this to be a classpath c:\Progran with Files\Java\etc as the program I want to run.
    I tried enclosing the paths in double quotes. Didn't work
    I tried enclosing the paths in single quotes. Didn't work
    I tried using a semicolon as a separator with double quotes. Didn't work
    I tried using a semicolon as a separator with single quotes. Didn't work
    I tried using a semicolon as a separator with no quotes. Didn't work
    I removed the "Class-Path:" line from the manifest and tried adding -cp param to the java command. Example:
    java -cp %classpath% -jar myapp.jar
    I tried all the variations above in the -cp param. None of them worked.
    The only thing that works is if I move executable jar file to the same directory as the required libraries. Then I specify a "Class-Path:" line with no spaces in the path names. Obviously this is not a permanent solution.
    If anyone else has the patience to help me I would really appreciate it.

  • Making executable jar file the database using JTable

    How can i make an executable jar file if I will use a JTable on my database?Can you tell me how?
    Thank you !!

    dantte wrote:
    in truth, ur question is not clear enough. elaborate on what exactly it is u want, and what u ar truin to achieve.You don't seem to know enough English, let along Java, to be answering questions here.
    %

  • Prbolem in executing jar file

    Hi
    I have written a java program that just prints "HAI"
    I made that as a executable jar file
    But when i am running that jar from DOS, the output is not printing
    Please solve my problem
    Thanks

    gimbal2 wrote:
    Kayaman wrote:
    Well, normally if your Jar file has a manifest file with the Main-class defined, you wouldn't need to use the -cp switch, in that case
    java -jar Sample.jarwould be enough. In fact the -cp flag is ignored when invoking an executable jar; the classpath MUST come from the manifest.This could be a 'cultural difference' in understanding, but it would be more accurate to say the -cp option is ignored if the -jar option is specified. This would mean that the -cp flag is not ignored in this command.
    java -cp Sample.jar SampleAnd while I am here, a question for the OP that I am not clear on. The manifest.txt used, does it end with one entirely blank line? (Note that copy/pasting the manifest.txt here will not prove anything, since the forum software will chew up the blank line even if code delimiters are used.) The symptoms of the problem do sound like the JVM is detecting the manifest and successfully reading the main-class attribute, since the stacktrace specifically stated it failed to load Sample.

  • Moving executable jar breaks the app's save function

    For the past week, I've been trying to deploy my desktop application as an executable jar file but I'm facing the following problem: Whenever I move the jar file from its original build location, my application becomes unable to write to its external files. I initially thought the problem was path related; however, when moved the app can still load data from these files.
    The solution is probably simple but for some reasons I've yet to find it .
    The app consists of a jar file and a folder named "files" containing text files (such as library.data) to which serialized objects are written.
    I wouldn't be surprise if the problem has to do with the xml build file, but all modification I've tried so far have failed. If it is likely that it is the problem, I'll be happy to post a copy of it upon request.
    public static void saveLibraryToFile() {
        File file = new File(System.getProperty("user.dir")+"\\files\\library.data");
        if (file != null && file.exists()) {
            library = new Library(sortedAccounts, accountCategoriesMap, accountCategoriesList);
            try {
                FileOutputStream fos = new FileOutputStream(file);
                BufferedOutputStream bos = new BufferedOutputStream(fos);
                ObjectOutputStream oos = new ObjectOutputStream(bos);
                oos.writeObject(library);
                oos.close();
            } catch (Exception e) { // catches ANY exception
                System.out.println(e);
        } else {
            System.out.println("this is not supposed to happen!");
    Any help would be greatly appreciated.
    (PS: A mostly complete set of the relevant codes I'm using, including the full Ant xml file, can be found at :
    http://stackoverflow.com/questions/22732274/java-save-method-stops-working-when-jar-is-moved)

    Apparently, all this time, my problem was being caused by trying to run the application after moving it onto the desktop. If I move the app to another directory, such as C:\randomFolder, the app works fine.
    That being solved, is their anyway to completely negate this problem and make it possible to run the app anywhere? Or is it simply impossible due to various security risks?
    Run the app anywhere? Yes
    Save files anywhere? No, of course not.
    If has nothing to do with 'security risks'. It has everything to do with security and directory/file permissions.
    You will NEVER be able to write files to a directory that you do not have write permissions on. That is just the way it has worked from the beginning.
    The typical solution is:
    1. present a file open/save dialog to let the user choose where to read/write files.
    2. for writing - check that you have write privilege on the folder before just blindly trying to write to it.

  • Extract contents of a .Jar file or executable jar file

    I have an executable Jar file.. Is there anyway that I can see the contents of this file.. the code in it..
    I have read some tutorials on how to extract .jar files but the question is where do i execute these commands.. is it on the command window or somewhere else.
    Can anyone help me plz????????

    but the question is where do i execute
    these commands.. is it on the command window or
    somewhere else.
    If you're using windows OS, you can do execute the
    command in dos promt
    and if you're using linux, you execute it in the
    Terminal/Console or double click on the file name in
    the
    Knoqueror, you can see the contents.Konqueror file manager,you can see the contents.

  • Executable Jar file

    How do I bundle my .class files into a .jar that I can execute directly...
    Basicly I'd like to make it so my classes are all packaged together and that someone can type just the file name to execute, can this even be done?
    Thanks

    How do I bundle my .class files into a .jar that I can
    execute directly...
    Basicly I'd like to make it so my classes are all
    packaged together and that someone can type just the
    file name to execute, can this even be done?
    ThanksAt the top of this page is a search button. If you type "executable jar" and hit search you'd probably find about 100 answers to this question.
    Let us never speak of this incident again.

Maybe you are looking for