Run jar files in Mac OS X

Hi I am working in a MAC OS X environment. I want to run a jar file with arguments in OS X from an icon that can be double-clicked. It is possible to use a .command file to run it. But its just plain ugly to look at and when running. Is there a cleaner slicker way to do what i want :).

Hmm. It turns out to be not so hard to turn a jar into a .app. Open Project Builder, create a new Java Swing Application, build it, then go into your applications Contents/Resources/Java folder and drop a copy of your jar. Edit the Contents/Info.plist to change the ClassPath and MainClass attributes. But I don't see an attribute for command-line arguments.

Similar Messages

  • How to run .exe files in mac pro?

    how to run .exe files in mac pro?
    i am looking for this to play games in my mac pro.
    if someone got a answer, just let me know
    cheers.

    mailking wrote:
    And I fail to see why you are attacking me...
    My comment is Valid...  " .exe files will not run natively on Mac OS X..."
    I am sorry. I had the false impression that it was commonly known that .exe files did not run on Mac OSX natively and failed to see any constructive critique you were bringing. Maybe I am wrong. Again deepest apologies.
    Unfortunately... these days... not every one is aware of this .exe  fact..
    Apology accepted.. and Thank You..

  • Problem running jar files of java in Linux

    I cannot run jar files in java/jdk1.3.1_01/demo in Readhat Linux 6.2
    The command is :--
    [root@localhost Notepad]# java -jar Notepad.jar
    java.lang.NoClassDefFoundError: javax/swing/JPanel
    at java.lang.Class.forName(Class.java:33)
    at kaffe.jar.ExecJarName.main(ExecJarName.java:58)
    at kaffe.jar.ExecJar.main(ExecJar.java:61)
    [root@localhost Notepad]#
    My ~/profile setting is :---
    PATH="$PATH:/usr/X11R6/bin:/usr/java/jdk1.3.1_01/bin:/usr/java/jdk1.3.1_01/jre/bin:/usr/java/jre/lib"
    export JAVA_HOME=/usr/java/jdk1.3.1_01
    export NPX_PLUGIN_PATH=/usr/java/jdk1.3.1_01/jre/plugin/i386/ns4

    [root@localhost Notepad]# java -jar Notepad.jar
    java.lang.NoClassDefFoundError: javax/swing/JPanel
    at java.lang.Class.forName(Class.java:33)
    at
    at
    at kaffe.jar.ExecJarName.main(ExecJarName.java:58)
    at kaffe.jar.ExecJar.main(ExecJar.java:61)
    [root@localhost Notepad]#
    My ~/profile setting is :---
    PATH="$PATH:/usr/X11R6/bin:/usr/java/jdk1.3.1_01/bin:/u
    r/java/jdk1.3.1_01/jre/bin:/usr/java/jre/lib"
    export JAVA_HOME=/usr/java/jdk1.3.1_01
    export
    NPX_PLUGIN_PATH=/usr/java/jdk1.3.1_01/jre/plugin/i386/n
    4Add the line:
    export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar
    Then, run the command "source ~/.profile" and then the jar file should be able to run.
    Bhav

  • Error messege when run jar file

    when i run jar file of my project give me that error(Fatel exception occured.program will exist)
    what is the reason of that error

    "can't get that path". Sounds like requisite classes aren't on the classpath.
    Please paste the ENTIRE error message that it's producing into your next reply. You have probably forgotten to include necessary classes - perhaps a JDBC driver - in your JAR file.

  • Console not display when run jar file

    i run jar file with command javaw -jar test.jar or double click on jar file, it's console app, it just run well but console not display, can i made console display and when i close console, it's stop jar file too?
    thanks

    i got it, javaw = no console window, i tried java command and i got error: can not access jar file?

  • JAR files and Macs

    I recently completed a project and made it into a Jar file. In windows, i simply double click to run the application.
    Just curious, if i submit the Jar file, will my lecturer, who condemms windoze machines, be able to run it on his Mac? I think its a power book that runs MacOS X?
    What instructions should i include?

    Java applications that are packaged in jar files can be run on different operating systems like Linux and Mac OS X. It's not a problem to simply run the jar from the Mac. To execute a java application that is bundled inside a jar file, you use the command line, a "terminal", and execute the following code..
    java -jar MyApplication.jar
    Basically using the same "java" command used to execute a class, but including the option "-jar" which tells the Java interpreter on the machine that the application has been packaged into a jar format. The interpreter will find the class which serves as the entry point of the application by examining the Manifest file which is included with the jar file. It sounds like you created your Jar file inside an IDE of some sort, maybe NetBeans..
    To have the "double clicking" option on the Mac - it may be possible but I'm not sure how to do it.

  • Unable to run jar file without lib folder containing swing-layout-1.0.jar

    I have done my project through NetBeans 5.0. Eventhough I have copied my lib foloder containing swing-layout-1.0.jar inside my project.jar, I am still unable to run my project.jar in other systems, it is creating an error as Could not find the main class. Program will exit. But if I copy the lib foloder containing swing-layout-1.0.jar in the same path as the project.jar, then my project.jar is running.
    But I want to give only the project.jar for other users and not also lib foloder containing swing-layout-1.0.jar each time.
    Could someone please help me with this.

    When you develop GUI applications using the Netbeans you may endup using netbeans specific jar files in your auto generated code.
    And when you build jar files with netbeans it copy the third party jar files used in a application in to a lib folder in the same directory as the jar file of your project. And then set a class path entry to those jar files in your project jar file's manifest file.
    So if you want to redistribute the package you have to redistribute your jar file and every thing in the lib folder in with the same directory structure.
    If you want to change the structure you will have to change the class path to suit the new structure.

  • Getting error while running jar file

    Hi,
    I am getting below error while running the jar file
    "Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdeveloper/layout/XYLayout:"
    I have created a simple ADF desktop app in which i am displaying the frame.I created the jar from Jdeveloper.
    Please help..

    How do you run the jar file? Take a look at this thread for a possible a solution: Re: deploying a jdeveloper adf application to a desktop
    Is the class XYLayout packaged or referenced? Take a look at this thread: XYlayout  classes - can I distribute with my code?

  • Running Jar Files created in Sun Java Studio

    Hi everyone,
    I am still trying to explore the functionalities (especially as regards deployment issues) of this robust IDE. However I do have a problem. I have developed a very basic program that connects to a database (MSSQL) using Java Studio 8. However after building the jar file, if I try to execute the jar file it gives me this message
    java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver.....
    But all goes well within the IDE and it runs well if I use my notepad or vi editor,compile it from the command line and execute the generated class file. The classpath have been set for all the necessary jdbc jar files.
    Any Help Will Be Appreciated

    1. Sun Java Studio Enterprise 8 is based on NetBeans 4.1 which does not provide direct support for packing an application. One alternative you may want to consider is to use NetBeans 5.0 (http://www.netbeans.info/downloads/download.php?type=5.0) or JSE 8.1 which is based on NB5.0 and which is now in beta (http://developers.sun.com/prodtech/javatools/jsenterprise/downloads/index.jsp).
    You may want to refer to http://www.netbeans.org/kb/articles/javase-deploy.html for packing and deploying a standalone application is NB5.0 or JSE8.1.
    2. Using JSE8, you may want to try copying all the library jars (including database drivers) used by your application to your projects dist directory manually and then package them all into one jar.
    3. You should not have to know the exact location of the jdbc jar on the client machine. How are you instantiating the driver in your code? Are you using 'Class.forName()'? If so, java should be able to pick up the driver from the classpath. (Pl. ref to http://forum.sun.com/jive/thread.jspa?forumID=122&threadID=62696, which may be of help).

  • Error with running JAR files created with NetBeans

    I have been having difficulty running the JAR files that NetBeans compiles. When I run my code from NetBeans, it always works just fine, but when I try to run the compiled JAR I get the following errors:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
    at java.lang.ClassLoader.defineClass2(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:719)
    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:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    This is happening for multiple projects now, though I don't remember it happening before. What am I doing wrong? Why is this happening? How can I fix it? Thank you for any insights...

    Oh, I forgot to mention, all the NetBeans samples work, just not apps that I create. This is very frustrating!

  • How to create a running jar-file

    I created a "Java Class Library" project including 20 class files in several packages and some libraries.
    Because I would like to start the project from the console, I added the main-class property (right-click project, Properties, Run). Then I cleaned and built the project and tried to start it with the following command:
    java -jar PROJECTNAME.jarBut it won't work, because the archive is not complete: MANIFEST.MF lacks the main-class and all involved libraries.
    I managed to add the main-class attribute manually, but adding all library references seems to be very error-prone.
    So does anyone know if I did something wrong or if this is a bug of Creator?
    Regards,
    Felix

    The main intent of this project type is to provide a libraray which normally wouldn't run with a "main". I suggest you use NetBeans to create a "Java Application" project. Here's what is in the README.txt file produced with the jar. This looks like what you're looking to do. So you can create the Jar in NetBeans then if you want to use it in Java Studio Creator, you can add it to the Creator project. Also, if you caught the news at JavaOne, we are providing Creator features for a pack that will run in NetBeans so you won't have to switch back and forth between the tools. Keep an eye on the NetBeans and Creator web sites for more info.
    Thanks!
    -David
    README.txt
    ========================
    BUILD OUTPUT DESCRIPTION
    ========================
    When you build an Java application project that has a main class, the IDE
    automatically copies all of the JAR
    files on the projects classpath to your projects dist/lib folder. The IDE
    also adds each of the JAR files to the Class-Path element in the application
    JAR files manifest file (MANIFEST.MF).
    To run the project from the command line, go to the dist folder and
    type the following:
    java -jar "JavaApplication3.jar"
    To distribute this project, zip up the dist folder (including the lib folder)
    and distribute the ZIP file.
    Notes:
    * If two JAR files on the project classpath have the same name, only the first
    JAR file is copied to the lib folder.
    * If the classpath contains a folder of classes or resources, none of the
    classpath elements are copied to the dist folder.
    * If a library on the projects classpath also has a Class-Path element
    specified in the manifest,the content of the Class-Path element has to be on
    the projects runtime path.
    * To set a main class in a standard Java project, right-click the project node
    in the Projects window and choose Properties. Then click Run and enter the
    class name in the Main Class field. Alternatively, you can manually type the
    class name in the manifest Main-Class element.

  • Problem in running JAR file

    Creating a mobile game using J2ME. The JAR file created by Netbeans IDE when bein run on mobile gives an error: JAR and JAD file did not match.
    Manifest file:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.6.2
    Created-By: 1.5.0_06-b05 (Sun Microsystems Inc.)
    MIDlet-1: Maze, Maze.png, Maze
    MIDlet-Vendor: Unknown
    MIDlet-Name: Maze
    MIDlet-Version: 1.0
    MicroEdition-Configuration: CLDC-1.1
    MicroEdition-Profile: MIDP-2.0
    JAD file:
    MIDlet-1: Maze, Maze.png, Maze
    MIDlet-Jar-Size: 100
    MIDlet-Jar-URL: Maze.jar
    MIDlet-Name: Maze
    MIDlet-Vendor: Unknown
    MIDlet-Version: 1.0
    MicroEdition-Configuration: CLDC-1.1
    MicroEdition-Profile: MIDP-2.0
    Please consider the query..

    Hey I solved the problem in following order
    JLabel jbl = new JLabel(new ImageIcon(getClass().getResource("image/theme.GIF")));I have a tips to all who are absorving in this problem
    that you should check that whether the extension is in capitalletter or small letter in the jar. Follow the format in your coding
    thnx
    best regards
    tanvir

  • Could not read Log4j configuration file when I run jar file

    Hi,
    I'm using Log4J in my application..
    I configure the log4j, as follows;
    PropertyConfigurator.configure("properties/logging.properties");and then go on to use it.
    The .properties is in the root when I jar my source. I use Ant to Jar the file. It all works good when I run the jar file from ant.
    The problem is when I run the jar file by double clicking on it, I get an error
    " Could not read configuration file [properties/logging.properties]."
    I tried the following options;
    PropertyConfigurator.configure("/logging.properties");
    PropertyConfigurator.configure("./logging.properties");
    PropertyConfigurator.configure("../logging.properties");But in all cases, I get corresponding errors on running the jar file through Ant:
    log4j:ERROR Could not read configuration file [logging.properties].
    log4j:ERROR Could not read configuration file [./logging.properties].
    log4j:ERROR Could not read configuration file [../logging.properties].
    I want to be able to run the Jar by double clicking on it or through Ant.. Would any one know how to fix this issue so that I can use both methods..

    Keep your properties file inside the root folder of your application.It is working fine

  • Read a txt file when I run jar file

    Hi all,
    I have a jar file. In ir there are:
    /file.jar
       |----/pack
       |        |----MyClass.class
       |        |----file.txt
       |
       |----/META-INF
       |        |----MANIFEST.MFI want: when I execute the jar file java -jar file.jar from the java class MyClass to read the file.txt
    When I run this the error is:
    C:\Documents and Settings\pc\Escritorio>java -jar file.jar
    java.io.FileNotFoundException: file:\C:\Documents%20and%20Settings\pc\Escritorio\file.jar!\pack\file.txt (El nombre de archivo, directo
    rio o etiqueta del volumen no es valido)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.<init>(Unknown Source)
            at java.io.FileInputStream.<init>(Unknown Source)
            at java.io.FileReader.<init>(Unknown Source)
            at pack.MyClass.main(MyClass.java:20)
    Exception in thread "main" java.lang.NullPointerException
            at pack.MyClass.main(MyClass.java:31)the code into the java class is:
    package pack;
    import java.io.BufferedReader;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.InputStream;
    public class MyClass {
         private static String version = null;
         static String fich = "file.txt";
         public static void main(String[] args) {
              BufferedReader br = null;
              File file = new File(fich);
              try {
                   br = new BufferedReader(new FileReader(MyClass.class.getClass().getResource("/pack/file.txt").getPath()));
                   String j= null;
                   while ((j = br.readLine())!=null){
                        version = j;
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (IOException io){
                   io.printStackTrace();
              } finally{
                   try {
                        br.close();
                   } catch (IOException e) {
                        e.printStackTrace();
              if (version != null)
                   System.out.println("I have read : "+version);
    }in MANIFEST.MF file:
    Manifest-Version: 1.0
    Main-Class: pack.MYClassthanks very much

    thanks you!!
    I have read the file, but I have put the package when I write the file.txt, beacuse If I don't put this, givas me NullPointerException
    Now I have
    InputStream in = Main.class.getResourceAsStream("/pack/file.txt");
    InputStreamReader isr = null;
    BufferedReader reader = null;
    try {
              isr = new InputStreamReader(in, "ISO-8859-1");
              reader = new BufferedReader(isr);
              while ((j = reader.readLine())!=null){
                   version = j;
              reader.close();
    } catch ...Thanks very much

  • Running jar files

    Hi,
    I hv a jar file created by compiling the program in an IDE.Now I want to run the jar file directly from command prompt.i.e I want to run it something like
    java -jar myjar.jar <arguments>
    Also the program imports another package which is included in the classpath in the IDE.
    Now while running the jar file in the command prompt do I hv to set the classpath again to include the imported package.
    Can anyone tell me how to do it??

    When running a jar, the content of the jar becomes
    the classpath. So add any class you need to it and
    you should be fine. If your jar depends on classes
    outside the jar, it will not run on other systems
    without those classes being present.Hi
    Thanks a lot.I got the answer I was looking for.
    Thanks again!!!!!

Maybe you are looking for