Results 1 to 15 of 15
  1. #1
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default How to create a stand anole application?

    Hi, I have created a java desktop application and got it running perfectly, but how can I make it a stand alone application? I have a jar file, but attempting to run that from the terminal (I use a MacBook Pro intel computer) gives me the java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group meaning I don't have the necessary libraries for the application to run. But I don't want to have users run the application from the command line anyway. I would like a stand alone application that will run by double clicking it. Is this possible? And if so, how? Thanks in advance,

    Chris Coulon
    gaiag.net

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    got it running perfectly,
    Does that refer to running in the IDE?
    Not familiar with a Mac so can't help much.
    Looks like the IDE has the needed jar files on the classpath and the java command (what you execute at the terminal window) doesn't.
    Can you have different versions of java between the IDE and the terminal window? The class you're missing is in 1.6 only.

    On windows, installing the java JRE sets the java command to be executed with the -jar option when a jar file is opened(double clicked).

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Seems to me, our thread starter misses some library files. In NetBeans, you get the deploy package as a collection, not just a single file. In the project file you can find a folder name dist. That's the whole package. Inside the dist folder there is a folder created, named as lib, and copied libraries to that.

  4. #4
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default How to create a stand alone application?

    Sorry for the similar posts. I couldn't change a misspelling in the title and thought it would be ignored. It's true all the required libraries are in the dist folder, but still I get the error when trying to run the application from the terminal window.

    By "stand alone application" I mean an application that runs by itself by opening it or double clicking its icon. Most users aren't savvy enough to call an application from a terminal -- as remedial as that may be -- so I wanted to create something more user friendly. I am developing an application for lung cancer researchers, and I want to make it as user friendly as I can.

    I can bundle all the files in a single jar file, but still I am not sure that would work. I thought NetBeans would certainly have a way to create a stand alone application (my definition) from a desktop application. Am I wrong?

  5. #5
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Recompile it and build again to generate necessary jar files....

    Try to modify the MANIFEST.MF inside the main jar file....

    and post its content including the INDEX.LIST here.....
    freedom exists in the world of ideas

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    different versions of java between the IDE and the terminal window? The class you're missing is in 1.6 only.
    You didn't say what version of java you have outside of the IDE.
    THe missing class is part of java 1.6.
    There's a problem with developing code to the latest classes. Clients might not be uptodate to it and won't be able to execute your code. Sometimes it better to use older versions to keep clients happy.

    Putting all your classes in a jar file should work as long as your code doesn't use something that is not in the client's version of java.

  7. #7
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default

    Try to modify the MANIFEST.MF inside the main jar file....
    and post its content including the INDEX.LIST here.....

    The project has been compiled and built repeatedly, each time I make slight code changes. Here is the MANIFEST.MF file, but there is no INDEX.LIST anywhere:

    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.0
    Created-By: 1.6.0_05-b13-52 (Apple Inc.)
    Main-Class: analyzelungs.AnalyzeLungsApp
    Class-Path: lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar lib/ij
    .jar
    X-COMMENT: Main-Class will be added automatically by build

    You didn't say what version of java you have outside of the IDE.
    THe missing class is part of java 1.6.

    Bingo! I had selected 1.6 as my default, but failed to notice that I hadn't put 1.6 at the top of my runtime list. Now it runs from the terminal window.

    But again, it there a way to have it be a free standing application? i.e., run by itself with a double click on its icon?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    is there a way to have it be a free standing application? i.e., run by itself with a double click on its icon?
    That should happen on Windows if you have java installed. Dont' know what to do on a Mac if it doesn't start with a double click.
    I gave a jar file (developed on Windows XP) to a friend with a Mac (new 2 years ago) and he had no problem executing it.

    To allow more "clients" to use your program, can you NOT use java 1.6 to create it? An older version of java will allow more users without the problems you had.

  9. #9
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default

    That should happen on Windows if you have java installed. Dont' know what to do on a Mac if it doesn't start with a double click.

    OK, it does start with a double click on the jar file. Sorry about that. Great! Thanks for you quick and competent assistance in this matter. :)

    To allow more "clients" to use your program, can you NOT use java 1.6 to create it? An older version of java will allow more users without the problems you had.

    True, but this is a gui that allows much greater ease of use than the previous version that was messier. There aren't many clients -- just a few researchers into lung diseases and their graduate students, and they will all appreciate the new look and ease of use that comes with a clean gui -- only possible with java 1.6.

  10. #10
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default

    One more small problem. I can run the application with a double click provided the lib directory is in the same folder with the jar file. Is there a way to make it all one package? I tried putting both the jar file and the lib directory in a jar file, but that doesn't work. How is it possible to have a single entity as an application? It would just be a bit more elegant.

  11. #11
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    Class-Path: lib/appframework-1.0.3.jar lib/swing-worker-1.1.jar lib/ij.jar
    Your jar file says that it needs these jar files to run.
    I'ts possible to unjar them and then jar all of them with your stuff into a single jar file.
    Java doesn't look inside a jar file for another jar file.

    Put all the jars into a zip and have the client unzip it into a directory so they are all together.

    What is in those 3 jar files that you need? Can you rewrite the code to only use what comes in Sun's jre?

  12. #12
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default

    Your jar file says that it needs these jar files to run.
    I'ts possible to unjar them and then jar all of them with your stuff into a single jar file.

    I tried that, but it still doesn't work.

    Put all the jars into a zip and have the client unzip it into a directory so they are all together.

    Yes, but it's an extra step. I might as well just send both files and have the user put them both in the same folder.

    What is in those 3 jar files that you need? Can you rewrite the code to only use what comes in Sun's jre?

    I'm not sure I understand the question. I use NetBeans Design view to construct the gui, then create the code within the Source view. All files are created by NetBeans -- I have added nothing extra except ij.jar, which is ImageJ and is in the lib folder. The application cannot run without ImageJ: it is the essence of the image processing tool.

  13. #13
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

    Default

    I tried that, but it still doesn't work.
    If you get errors, please copy text here.
    Doesn't work doesn't mean it can't work. It might mean you made a mistake that could be corrected.
    If the files are together in the correct folders in a zip file, there will be less for the user to have problems with.
    send both files
    I thought there were 4, your jar plus the other 3.

    Are there some imports in your code put there by the IDE that refer to code in the other jar files? That's one of the problems with using an IDE, things are easily out of your control.
    To get rid of the other jar files, you need to find out what your program uses and change it to not use that class.

  14. #14
    Join Date
    Jul 2008
    Posts
    13
    Rep Power
    0

    Default

    If you get errors, please copy text here.

    8/24/08 1:49:56 PM [0x0-0x147147].com.apple.JarLauncher[3638] Invalid or corrupt jarfile /Users/chris/NetBeansProjects/LungAnalysis.jar

    I see the problem: the lib contains three jar files, and java 1.6 doesn't handle nested jar files -- as you pointed out. Opening the ImageJ jar file is far too complicated for my purposes. I guess I will wait until they implement nested jars in java 9.7, sometime next century or so. ;-)

  15. #15
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,449
    Rep Power
    25

Similar Threads

  1. Display Screecast in Java Stand Alone App?
    By JimCrowell@EMail.com in forum AWT / Swing
    Replies: 0
    Last Post: 08-05-2008, 03:15 PM
  2. Could some plz tell me how to write a stand alone
    By quickfingers in forum New To Java
    Replies: 25
    Last Post: 06-28-2008, 04:22 AM
  3. Stand O' Food Game Proyect
    By piachens in forum New To Java
    Replies: 1
    Last Post: 03-24-2008, 05:28 PM
  4. Replies: 0
    Last Post: 02-16-2008, 09:31 PM
  5. Replies: 0
    Last Post: 02-16-2008, 09:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •