JAR files don't run on Linux

Hey All:
I installed JDK1.3.1(win32) on Windows, double clicked my JAR file (proper manifest and classes within) and it started the swing program just fine.
I installed JDK1.3.1(linux) on Red Hat 7, double clicked my JAR file, and it wants to know which Fk'n program to open it with! What happened here, I thought java/swing runs on linux?
The JDK installed java in /usr/java/jdk1.3.1/bin/java, do I somehow need to point linux there for .jar files to execute automatically? What are the commands to do this?
Thanks in advance,
Stephan

As far as I know, the double clicking on a jar file to execute it only works on windoze. On linux, you can can use:
java -jar foo.jar&
to execute the jar, assuming you have the main class included in the manifest. I don't know if there are any plans to change this. You should be able to write a script or somesuch which prepends 'java -jar' when you double-click.
m

Similar Messages

  • Please Help! .jar file don't work.

    Hi, I've written a swing program that works fine when run from command prompt but it doesn't work when I create a self executable jar file and run it.
    Here's the generated classes after compiling the source file:
    TheGMailClient.class (main class)
    TheGMailClient$1.class
    MailSender.class
    MyAuthenticator.class
    I also have a GIF image file.
    Here's what written in the manifest file:
    Manifest-Version: 1.0
    Created-By: 1.4.2_05 (Sun Microsystems Inc.)
    Main-Class: TheGMailClient
    I've created the jar file with the following command:
    jar cvfm TheGMailClient.jar MANIFEST.MF -C classfiles .And here's the exceptions shown after running the jar file (I've run the jar file from command prompt using the java -jar command to view the exceptions):
    java.lang.NoClassDefFoundError: javax/mail/MessagingException
            at TheGMailClient.actionPerformed(TheGMailClient.java:238)
            at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
            at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
    n Source)
            at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
            at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
    ce)
            at java.awt.Component.processMouseEvent(Unknown Source)
            at java.awt.Component.processEvent(Unknown Source)
            at java.awt.Container.processEvent(Unknown Source)
            at java.awt.Component.dispatchEventImpl(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
            at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
            at java.awt.Container.dispatchEventImpl(Unknown Source)
            at java.awt.Window.dispatchEventImpl(Unknown Source)
            at java.awt.Component.dispatchEvent(Unknown Source)
            at java.awt.EventQueue.dispatchEvent(Unknown Source)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
            at java.awt.EventDispatchThread.run(Unknown Source)It seems to me that some classes are not found. How can I overcome this problem? Please help me guys! I'm really stuck in here.

    The error is occuring because the jar ignores the system classpath.
    You need to set your classpath in the manifest file to find the external jars.
    Otherwise the external jars will not be found.
    In your case class javax/mail/MessagingException
    For example:
    Manifest-Version: 1.0
    Created-By: 1.4.2_05 (Sun Microsystems Inc.)
    Main-Class: TheGMailClient
    Class-Path: . jars/mail.jar jars/activation.jar
    The path will need to be correct in the above related to your system.
    Also because you mention a gif image.
    You will need to add the image to the jar - you haven't.
    make sure you are loading the GIF image file in a manner that can be used from a jar.
    Image image = null;
    try {
      image = ImageIO.read(getCkass().getResource("logo.gif"));
    catch {
      // what ever
    }You may need a relative path to the image in the jar depending on where the gif is.
    For example image = ImageIO.read(getCkass().getResource("images/test.gif"));
    rykk

  • How can I create a jar file that will run automatically on double click

    all the jars I created run only from the command-line.
    how can I make it run by double-click on it?

    First you will need to associate .jar files with the javaw.exe program in order to just be able to double click on the jar and run it from within a windows explorer application. Next you will need to set the main class attribute of the manifest file. My understanding is that the value of this attribute is used by the launcher to know which class to load. In other words, which is your main application class. To specify this attribute open your manifest file in a text editor. You will find this file located within the jar at META-INF/MANIFEST.MF. Then, add the line,
    "Main-Class:<relative path to the main class>" However, remember not to add the .class extension to the end of the class name.
    In Windows 2000 you can associate jar files with javaw by finding a jar file in Windows Explorer and right clicking it. This will give you a context menu which should have an Open With... option (if you are not using Windows 2000 and don't see the 'open with' menu item, try holding down the shift button while right click on the file). Select the Open With... option, then, when the dialog appears highlight javaw and select the "Always use this program to open these files" checkbox. When you hit the OK button you should have all your jar files associated with the javaw process.
    Once you've done this, you should be able to double click on your jar file and run your application.
    Regards,
    Daniel Walsh

  • Dynamic jar file inclusion at run time

    Hello,
    I have a java application which should accept the three parameters.
    1) The jar file location
    2) Particular Class file insdie that jar(we specified the location in step number 1)
    3) And method name in that class.
    My question is how to include specified jar location with jar name to CLASSPATH at run time. So that i can execute a particular method name in step number (3).
    I would appreciate for the quick reponse or any input.
    Thanks,
    Raghu

    And if you want to change the system classpathduring
    runtime, don't forget that you can always use
    reflection to call the System classloader'sprotected
    addUrl method :)Really?
    Seems reasonable although this is the first time I
    have seen that referred to.you can indeed. I've done this, as a quick avoid-writing-a-classloader hack. wouldn't really recommend it, though. if you're using reflection to modify access, chances are you're doing a massive fudge
    and of course, since it's not part of a public API, there's absolutely no reason to the method won't simply disappear in a future release....

  • Jar file won't run

    Why is it that whenever i run my program using eclipse it works fine but whenever i export a jar file of it, it doesn't run at all?
    It does not even give an error message and this happens for only one specific class, all the others expoort perfectly

    Probably either 1) the jar file is not located where it should be, or 2) the jar file does not have (or it's incorrect) a manifest file.
    Since you don't give any useful diagnostic information, hard to tell more.

  • JAR file decompressed before run?

    hi,
    does anyone know if a JAR file is decompressed totally to some temporary location before it is run? So if you had a 1Gb Jar file that was mostly odd files, and a few java classes to do some optional processing which never occured, would the remainder of the jar be decompressed?
    thanks,
    asjf

    Oops, wrong answer to wrong thread.
    Jars a decrompressed on demand but the JRE might cache the whole Jar file.
    But anyways: Who uses such big Jar files?

  • Jar file doesn't run properly, please help!

    Hi everyone, i'm a student and i'm programming a game for my homework of AI subject. When i compiled the code from Eclipse, the game run smoothly, but when I create the jar file of the project, it appear blank when i run it. Here is the image:
    [blank screen|http://c.upanh.com/upload/4/299/3L0.8429518_1_1.png]
    and run from Eclipse:
    [Run from Eclipse|http://c.upanh.com/upload/4/299/TL0.8429668_1_1.png]
    I have followed the instruction of creating jar file in Eclipse properly, and now the trouble come. If anyone can show me how to solve this problem?
    Thanks all.

    I have all of e.printStackTrack( ) in my try - catch block. But i also think the blank screen appears because the class can not find my resources. Maybe it's my fault, because i create by hand a folder name "res" in project folder, then put all my resource in this folder. And in Eclipse when i try to get these resource, i wrote something like this:
         Image robot1N, robot1E, robot1S, robot1W;
         private void initResources() {               
              try {               
                   String sb = "car1";
                   robot1N = ImageIO.read(new File("res\\img\\unit\\" + sb +"_N.png"));
                   robot1E = ImageIO.read(new File("res\\img\\unit\\" + sb +"_E.png"));
                   robot1S = ImageIO.read(new File("res\\img\\unit\\" + sb +"_S.png"));
                   robot1W = ImageIO.read(new File("res\\img\\unit\\" + sb +"_W.png"));
              catch(Exception e) {
                   e.printStackTrace();
         }Maybe the string of path to resource is right in Eclipse but wrong in Window?

  • Decompiling jar file and then run

    Dear Members,
    I have a jar file and I have decompiled that jar file and converted into class file,
    now I want to run/edit using source code ,I am unable to run source code with out put whatever coming in jar file running,
    I am trying with class in which
    public static void main(String[] args)
    function defined,
    I am using Jcreater1.5 and from command prompt also running but unable to run and edit the programm,
    how to run these class file in complete project that output will come as running jar file
    regards
    SACHIN

    It sounds like you have unpacked the jar.
    To edit the source you need to decompile the classes to .java files.
    [http://www.google.co.uk/search?q=java+decompiler]

  • Jar files as application Error under linux

    I created a jar file with the following jar command
    jar cmf mainclass Asdi2GuiJar.jar *.class
    Main-Class: ASDIGUI
    It did work without any problem : java -jar Asdi2GuiJar.jar
    when I added to the CLASSPATH under linux "Redhat 7.2" C-shell, it give me an error:
    Exception in the thread main java.util.zip.ZipException: No Such file or directory
    even im not using any zip file class in my java application. Any idea why im getting such an error even before addding the jar file to the CLASSPATH it did work without any problem?

    ah young grasshopper you are using zip files :) rename your .jar file a .zip and use unzip on it :)
    and that error means that the jvm's classloader couldn't load it's zip component so it's likely that your jvm can't find it's standard lib's
    make sure your class path points to the /lib directory of your java install..... which version of the jdk are you using?
    are you setting the classpath globally? since the way you said CLASSPATH I guess you are... ....are you keeping the old classpath when you set it? like CLASSPATH=$CLASSPATH:/myNewSource
    or something like that...
    maybe something in that will help

  • Running .jar files in linux on double click

    Hi,
    i needed a solution to run the jar files on double click in linux system.Necessity is mainly because when i run the jar file by java -jar myapp.jar in terminal it works fine .Iam running my app continuosly in system tray(a server kind).But if i close the terminal my app exits.
    How to resolve this ?

    I am taking a SWAG.....it sounds like your problem is how to run a java app without a terminal window. So as I recall, there is some way in Linux to enter a command and have it execute in a new process. I don't recall the syntax but maybe putting a '&' character in the command line? Anyway, you should be able to use the method and use "javaw" instead of "java" to launch your app. You should be able to do this in a batch file too. Something like, javaw -jar yourjar.jar &

  • App runs in Eclipse environment but not from jar file with no error message

    When I upgraded my jre to 5.0 my app does not run. After fixing the properties problem I had a few days ago it is now at least compiling and running within Eclpse
    However, when I export to a jar file it runs to a certain point and then just goes away with no error message!!! I've narrowed it down to the exact point where it dies but don't understand why it dies and especially gives me no errors whatsoever. It just goes away.
    It is creating an instance of a new class when it dies.
    Can someone please help me?

    Ok, well it doesn't. Anyway, I'm still having the same problems. I can run my jar file to a certain point and then the application just stops. I know this because I've put come message boxes in the application to let me know where in the app the system is.
    It always dies when it is instantiating the new class called HeidiFrame; done by:
    HeidiFrame heidiFrame = null;
    if I put code in between the above line and before the below line, this code will work fine
    heidiFrame = new HeidiFrame();
    but if I put code after the above line, nothing happens
    As I said this all worked fine until I upgraded to Java 1.5
    If you look at http://java.sun.com/javase/technologies/compatibility.jsp there are 23 compatibility issues with the new release. We're using xml stuff so that was my first problem and the code wouldn't even compiile. Once I added in libraries, the code compiled and ran beautifully.
    However, when creating my jar file so I can deploy this application , I've discovered that the jar file will only run to a certain point, as I've stated previously. So, that's my problem. Not that I can't run it from the command prompt, which I can't, but it's a gui application. I've tried changing things in the classpath file and the manifest to no avail. Nothing changes. The application starts but when it goes to instantiate the HeidiFrame class, which is the class that actually builds the gui it dies and goes bye bye.

  • Help with a question about making/running .jar files.

    First i have a question, can i make a .jar file that can run on a computer without JRE installed. And if i can, how do i make it. I have tried to make it on my computer, that has JRE but i keep getting the error when i run it: Exception in thread "main" java.lang.NoClassDefFoundError: Sample\FileSearchAnd im using the command:
    jar cvfm jarname.jar directory\manifest.txt directory\FileSearch.class directory\FileNode.classIt says it creates the .jar but is unable to run it.

    dford425 wrote:
    First i have a question, can i make a .jar file that can run on a computer without JRE installed. No, not unless you package the JRE with your dist. Hence the name JRE (Java Runtime Environment).
    And if i can, how do i make it. I have tried to make it on my computer, that has JRE but i keep getting the error when i run it: Exception in thread "main" java.lang.NoClassDefFoundError: Sample\FileSearch
    That simply means your not pointing the runtime to the classes. Set your CLASSPATH environment variable correctly and it will run (given you have a JRE which it appears you do).
    And im using the command:
    jar cvfm jarname.jar directory\manifest.txt directory\FileSearch.class directory\FileNode.classIt says it creates the .jar but is unable to run it.

  • "no manifiest section for signature file entry" when run the Jar file

    I built an application by using JBuilder 8.0 and it works fine. But when I deploy it into a jar file, whenever I run it, the following exception appears:
    Exception in thread "main" java.lang.SecurityException: no manifiest section for signature file entry javax/security/cert/Certificate.class
    at sun.securtiy.util.SignatureFileVerifier.verifySection
    Because I didn't do anything about the security when build the application. I am really confused. Can somebody help?

    I had a similiar problem using NetBeans. There must be a way to view the properties of your jar from Jbuilder and set its manifest. I am very new to this myself, but all I did was edit another manifest and copied into mine. Here is my example manifest:
    Manifest-Version: 1.0
    Main-Class: J3Ed
    The first line is the default line for a manifest. It is very simple and there is much more that could be added, but is not always necessary. I recommend reading the documentation :
    http://developer.java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
    Also if you have an archiving utility such as powerarchiver or winzip, open your JAR and check to see that you have a MANIFEST.MF file. If you do then edit it where needed, if not create one and its relative location should be set to META-INF/MANIFEST.MF.
    Hope this helps.

  • Jar file runs on windows but fails to run on macbook

    hi, i developed this app using netbeans on windows and the .jar is runing fine, but when i transfered the jar file to a macbook and double clicked the jar file, it dint run, then i tried to run it from the terminal i got the following exception. please what could be the problem
    mustapha-mohammed-kutas-macbook:~ mustaphamohammedkuta$ cd desktop
    mustapha-mohammed-kutas-macbook:desktop mustaphamohammedkuta$ cd mustee
    mustapha-mohammed-kutas-macbook:mustee mustaphamohammedkuta$ java -jar PayrollProject.jar
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
         at java.lang.ClassLoader.defineClass2(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:774)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:160)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:254)
         at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
         at payrollproject.Main.main(Main.java:34)
    mustapha-mohammed-kutas-macbook:mustee mustaphamohammedkuta$

    This means the version of Java you're using on the Mac is older than the one you made your jar file with. I believe the default Java on Mac is Java 5. Perhaps you built your classes and jar with Java 6?

  • Jar file runs from the command line, but not when I double click it

    Hello, I'm running windows xp. I've created an executable jar file and it runs fine from the command line when I type;
    java -jar wizard.jar
    but, when I double click it . . . nothing.
    Any ideas?

    nothing ? that's weird, windows XP should prompt you to select the program you want to use in order to open Jar files (and give you this silly piece of advice to search the web for the appropriate program)
    you might want to check what program (if any) got associated with .jar extensions :
    in Windows Explorer : Tools => Folder Options => File Types
    hth

Maybe you are looking for