Java JAR executable

I know this violates platform independence, but does anyone know of a tool to convert a jar that runs a class based on its manifest into an executable for a given platform (I assume such a tool would merge parts of the JRE with the jar itself)?

Do a google search on Java to Exe. This will give you about 1.7 million hits. They have different ways of working so search until you find one that does what you want.

Similar Messages

  • Sending Command Line Arguments to Jar Executable

    Hi All
    I wish to send Command Line Arguments to Jar Executable.
    i.e. before I Jar'd my program, I would do the following
    public class CmdLnArgmntExp {
    public static void main(String[] args) {
    System.out.println("d");
    for (int i = 0; i < args.length; i++)
    System.out.println(args);
    Running the program in Console.
    Java CmdLnArgmntExp arg1 arg2 arg3 arg4Output:
    arg1
    arg2
    arg3
    arg4
    How would I do this to a Jar executable, hope that made sense
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    java -jar executable-jar-file-containing-class-CmdLnArgmntExp.jar arg1 arg2 arg3 arg4

  • Howto execute java jar file via html ?

    hi
    howto execute java jar file via html ?
    could someone pls post a html code ?
    kind regards
    upiter77

    hi
    howto execute java jar file via html ?You can't.
    could someone pls post a html code ?No. you can search for yourself and find the code you need.
    Now, it sounds to me like you're trying to build an Applet or do Web Start or something. In any event, you need...wait for it....Google! :-)

  • JAR Executable works in netbeans but not under Dos?

    Hi all,
    I have created a jar executable and it works fine in netbeans(it was not created in netbeans) but I can't get it to run on the command line. If I type java ClassName.MainClass it will run but not using the command java JarFile.jar or java -jar JarFile.jar
    Any help would be most appreciated.

    When creating the manifest file did you add a carriage return at the end of the manifest? e.g.
    Main-Class:Hello.class
    (carriage return here on new line)
    I think it runs into problems if you dont add a carriage return ( a new blank line after manifest).
    Hope this helps
    Riz

  • How to get a file in the same dir with the jar-executable

    Hi,
    I need to read/write a file that exists in the same directory with the jar-executable. How can i do that? I think that when i specify no path for the file, the file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and the file are.
    Thanx in advance

    Hi,
    I need to read/write a file that exists in the same
    directory with the jar-executable. How can i do that?
    I think that when i specify no path for the file, the
    file has to be in current path. (Is that right?)
    Note: I do not know in which directory the jar and
    the file are.
    Thanx in advance
    When you specify no path for the file, the file has to be in the directory where the virtual machine was started. ( the directory the java command was invoked in .)
    If you can't control the directory in which the vm is started, but you know the name of the .jar file you can do the following. This trick takes advantage of the fact that if you are using classes in a jar file, the name of the jar file must be in your classpath.
    public static String getPathOfJar( String nameOfJar )
    throws Exception
    StringTokenizer st = new StringTokenizer(
    System.getProperty( "java.class.path" ) ,
              System.getProperty( "path.separator" ) );
    String jarfile = "";
    while ( st.hasMoreTokens() )     
    String token = st.nextToken();
    if ( token.indexOf( nameOfJar ) > -1 )
    jarfile = token;
    break;
    if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
    String path = jarfile.substring( 0 , jarfile.indexOf( nameOfJar ) );
    return path;
    //To open a file in the same directory as the sun archive tools.jar
    File f = new File( getPathofJar( "tools.jar" ) + "someFile.txt" );

  • Java -jar -myApp.jar works but ....

    Hi there,
    I have a problem : using ant, I have exported my application into an executable jar file.
    When in the console, I type "java -jar myApp.jar" . Everything works well.
    But if, I do double click on the jar file, nothing happens. In fact, I can see a new Instance of javaw.exe in the "task manager" but nothing happens.
    It's kind of weird ...
    Has anybody an idea about that ??
    thanks in advance
    sylvain_2020

    I am having a similar problem.
    java -jar foo.jar works great, but double clicking seems to hang the app at a certain point.
    Unable to figure out what's going on, I've been putting some "JOptionPane.showMessageDialog()" calls to see how far it's getting. It appears to be hanging up when it tries to instantiate one of my classes that extends JPanel. I have a dialog appear right before calling the constructor (and I see that one), but I don't see the dialog that's in the constructor as the first executed line (so that it must hang up somewhere before that). I've also removed all constructors from the attribute declarations. That made me think it had something to do with the constructor of JPanel, over which I have no control.
    However, I can instantiate JPanel no problem.
    What the heck is going on???

  • Java -jar Test.jar  option is not identifing the CLASSPATH on UNIX BOX

    Hi All,
    java -jar Test.jar
    I am trying to execute Test.jar file using -jar option. I am able to excute the Test.jar file but it is not identifing the CLASSPATH set for other JAR files which is used in part of Test.jar. Saying java.lang.NoClassDefFoundError: for the class which are set in CLASSPATH.
    The same is able to identify the CLASSPATH if i excute the Test.class file directly with out -jar option like
    java Test. In this case everything is working fine.
    Can any one tell me why it is not identifying the classpath if i use or execute with java -jar Test.jar option.
    Thanks,
    sha

    When you use the -jar option, the only classpath that is used is the Class-Path in the manifest file of the jar. If there is no Class-Path, then only the jar is searched for classes. If there is a Class-Path, the paths must be relative to the jar file.

  • Jar executable issue after jvm update

    I created a small demo application and bundled my classes and media files in a jar executable file. Everything was fine until I updated J2SE from 1.5.0 to 1.6.0_01.
    The application now starts, gets its input normally but soon after hangs, and the Swing GUI doesn't show up anymore.
    The jar file contains 4 packages (one of them contains the main class) and this simple manifest file:
    Main-Class: myapp.myAppLauncher
    Classpath: .\myapp.jar
    I created the jar as follows:
    jar cvfm gdv.jar Manifest.txt myapp mypackage2 mypackage3 mypackage4
    I recompiled the source before creating the jar archive, and if I launch the application from the console I see no difference from before. The problem is only for the jar version.

    Manually download and install the Java 4 update http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105 update4.html, and Safari 4.0.1 http://www.apple.com/safari/download/ Run Software update, install anything that pop up, repair permissions, and restart. That should fix your problem.

  • JAVA -jar manifest doubt

    Hi
    Recently downloaded JAXB binary code and and executed this jar as per the instruction. Inside the jar there was a Main.class and a manifest file under META-INF.
    Contents of the manifest file were
    Manifest-Version: 1.0
    Main-Class: Main
    After executing java -jar JAXB2_20110115.jar other library files (jars,htmls images) were installed in a new folder .
    From where are these files retrieved. There is no classpath mentioned in the manifest file . As soon as i execute this the files are installed.
    I understand that the Main.class is doing this job but not able to understand how? where are the new files retrieved coming from?
    apologies for making it too long

    user13534570 wrote:
    I understand that the Main.class is doing this job but not able to understand how? where are the new files retrieved coming from?Either from the jar itself or over the network. My first guess would be the jar itself.

  • .jar executable

    Hi!
    I have been trying to create an executable jar, but I only get the message "Could not find main class. Program will exit".
    This is what I have done!
    1. I created a java file that prints "Hello". This is the one
    import java.io.*;
    public class Test{
         public static void main (String [] args) throws IOException{
              System.out.println("Hello");
    2. I compile it
    3. I make a jar of the two files. The java file and the class file. To do so I type the following in the command window:
    jar cf temp.jar Test.java Test.class
    4. I create a manifest file and name it Manifest.txt. It contains the text:
    Main-Class: temp.Test
    5. I now create the (expected) executable jar file. Typing the following in the command window:
    jar cfm MyJar.jar Manifest.txt temp.jar
    And when I now try to double click the MyJar.jar I only get "Could not find main class. Program will exit". WHAT am I doing wrong??? Please help!
    /Jonathan

    jonfra wrote:
    Hi!
    I have been trying to create an executable jar, but I only get the message "Could not find main class. Program will exit".
    This is what I have done!
    1. I created a java file that prints "Hello". This is the one
    import java.io.*;
    public class Test{
         public static void main (String [] args) throws IOException{
              System.out.println("Hello");
    First off, you know that you don't need to import java.io or throw IOException for what you have here, okay?
    2. I compile it
    How did you compile it? As >javac Test.java? ... or >javac -classpath . Test.java? ... or ?
    3. I make a jar of the two files. The java file and the class file. To do so I type the following in the command window:
    Not wrong to do it, but why do you want the source code in the jar file?
    jar cf temp.jar Test.java Test.class
    I'd skip this step '3' and move on to step 4.
    4. I create a manifest file and name it Manifest.txt. It contains the text:
    Main-Class: temp.TestMake sure that you have an EOL character at the end of Manifest.txt - like so:
    Main-Class: temp.Test
    - this line needs to be blank -
    Also, why the temp. ? your class - as Mapleshaft alluded to, does not have a package statement.
    >
    5. I now create the (expected) executable jar file. Typing the following in the command window:
    jar cfm MyJar.jar Manifest.txt temp.jar
    After skipping step 3 entirely, jar as:
    jar cmf0 Manifest.txt MyJar.jar Test.class
    And when I now try to double click the MyJar.jar I only get "Could not find main class. Program will exit". WHAT am I doing wrong??? Please help!
    /JonathanLastly, this is not a GUI, so double clicking on it won't do anything anyway. You'll need to run it from the command line as >java -jar MyJar.jar

  • Help.about "java -jar"

    execute "java -cp second.jar;main.jar main.Main", it is ok.
    but
    execut "java -jar -cp second.jar main.jar", it fails. It report that java can't find one class in second.jar. The second.jar is not any changed.

    if you use the -jar arg, then java needs to know which Main-class to run in the jar. You have to state this explicitly in the file 'Manifest.mf' which should be in your jar-file in the folder 'meta-inf'. In that file state the location of the main-class like this:
    Main-Class: package1.package2.MyMainClassName
    greetz,
    Stijn

  • How do I put my jar executables into a cab file to create a setup/install?

    I want to create a setup program for installing my jar executable. I've seen ones that create cab files with a setup.exe program and would like to do the same. Any suggestions?

    Well, JARs generally don't have support files. That's the whole idea. A JAR is designed to be a stand alone application. You don't really need to install it, for that matter. I just thought you might be wanted shortcuts or something.
    Actually, there is some way to install Java programs through Java Web Start, if you want to check that out. I don't know anything about it, though.

  • Error when testing java -jar whitelist.jar -help

    I found an error when executing this commande
    C:\oracle-javacloud-sdk\lib>java -jar whitelist.jar -help
    Exception in thread "main" java.lang.UnsupportedClassVersionError: oracle/cloud/
    scanning/cli/ScannerMain (Unsupported major.minor version 50.0)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    what can be the origine of this error
    Thanks

    Try using JDK 1.7 - (version 51.0) as I have no problem running with 1.7.0_21
    /michael

  • JAR executable do not find third party Jars

    Boy I am beat.
    I am trying to build executable jar that needs bunch of third party jars.
    So I import the jars into a ext folder at the top of the pkg. I jar it all up (using Ant)with a manifast that point the classpath to the jars at the ext folder
    Dir Structure:
    myJar.jar
    |
    +-build
    |main class
    |
    +EXT
    |
    + bunchOfJars
    </pre>
    Manifest-Version: 1.0
    Created-By: Apache Ant 1.5
    Built-By: Ted I Weitz
    Classpath: ext/dom.jar ext/xsltc.jar ext/dt jar ext/vecmath.jar
    ext/j3dcore.jar ext/j3dutils.jar ext/xercesImpl.jar ext/xalan.jar
    Main-Class: myMain
    Command:
    java -jar myJar.jar
    I will be very gratfull for any idea
    Ted

    Just posted on this in another thread I am watching. As far as I know, and every other post I have seen on this topic, there is no way to do this without using a custom classloader that is used by the executing .jar itself to load any .jar files. How I can see this work is the main class is nothing more than a "classloader" launcher. It creates a new instance of this custom classloader. It then opens "itself" (the .jar the main class and all the .jar's are in), reads the manifest file to locate the .jar files the application requires, then either loads them, or somehow is able to reference them without directly loading them. The URLClassLoader is a good one to extend for this. It already opens up any .jar file specified in its path when being created, scanning for any files in there. Basically, you need to "extend" this functionality to scan any .jar's in the .jar, and so on. So, the launcher may be like so:
    public void main (String[] args)
    JarClassLoader jcl = new JarClassLoader(this.getClass().getClassLoader());
    jcl.launchApp(this);
    the jcl.launchApp would be a method that tells the classloader to use THIS class, its "root" dir, to locate the .jar file to open and scan for more jar files. Each time it comes across a .jar file in the .jar, it opens it and scans it as well.
    Keep in mind, when the URLClassLoader contains one or more .jar files, when a class it loaded references a class that is not found in the that classloaders parent loader classpath, it then starts looking in the .jar files in the URL[] path specified to it. It looks at all classes in the .jar files, but it does NOT look in nested .jar files in the .jar file. Basically, you could take the source code of the URLClassLoader, and add the ability to open up any .jar files nested in each .jar file as needed to resolve a class. I would imagine this could take some time at runtime, probably a second or two on slower machines for a single typecast. However, that would be dependent on the number of nested .jar files, the number of .jar's in the classpath of the classloader. I think I may undertake this task when I have time. I gotta finish my plugin engine first, then I may undertake this classloader. I am pretty sure that is the proper approach to take. However, because it is not part of the JVM .jar execution mechanism, a special bit of coding will be required, such as what I posted above. The main class in the .jar file will have to create this classloader and tell it to "execute" the program, passing to it another main class, specifying the location of the .jar file the main class is in, etc. Hell, you could almost bypass the java -jar app.jar and just do a java Classname where by the class and the .jar are bundled together, although this wouldn't be as nice. The reason this might be better is that then you wouldn't have to do any special coding in the .jar main class. I suppose though, by providing the "launcher" class and having a developer just extend it as part of their main class could also work.
    }

  • .jar file only works with 'java -jar'

    I have a .jar file that contains an installer. When I double click it nothing happens on my work computer (vista32). I have tried moving it to my home computer (vista64 and winXP) there it works fine when I double-click it.
    I have found a temporary solution for the work/vista32 machine. If I run it with:
    java -jar installer.jar
    it works. I have put this in the target of a shortcut to the file. But why do I need to do that manually when it works fine on my other machine by just double clicking the file?

    fedevaps wrote:
    Thing is that if I move this jar to another machine it works fine! The thing is that you are missing the point.
    It has nothing to do with the jar. Nor really java.
    Double clicking works because the OS (windows not java) understands what to do when you double click.
    If the OS (windows not java and definitely not the jar) does not understand then it doesn't work.
    So there are two independent parts.
    1. Create an executable jar.
    2. Create the correct association in windows.
    If you use the command line then you can absolutely verify that the first works. If it works then it means, absolutely (no other possibility) that if double clicking fails then the association, not the jar, is wrong.
    If it doesn't work then it means absolutely (no other possibility) that the jar, not the association, is wrong.

Maybe you are looking for

  • My camera won't open. How do I fix it?

    My camera won't open. How do I fix it? It been like this for the last few days/: I really need it fixed! Please help!

  • Nokia music problem

    Hi nokia, I am facing the problem in nokia music. I am using lumia 520 that have unlimited songs download subscription but when I am tring to download song song cannt download. And show the pop-up masseg "this phone have already anlimited subscriptio

  • CRASH crash CRASH crash...

    So this is the second repair in a year...I got my MBP back from apple yesterday: new display, new fans, new logic board and wiped drive with a fresh Leopard install! BUT NOW, less than a full day later...most of my apps crash the minute I open them!

  • [SOLVED] Run xscreensaver when I close the laptop lid

    I have xscreensaver running in my archlinux, and with a systemd service, I can start it after waking up my laptop. The problem is that I like to keep my laptop running when I close the lid (for example, to go to bed while I'm downloading a file, I li

  • Use of ":"  (colon) in workflow

    What are the use of ":" (colon) and how it can be used. Provide some information in this regard. Thanks