Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-23-2008, 10:57 PM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 08-24-2008, 04:55 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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).
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 08-24-2008, 05:21 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 08-24-2008, 08:27 AM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 08-24-2008, 09:46 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 540
Rep Power: 3
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
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.....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 08-24-2008, 02:46 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 08-24-2008, 08:30 PM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 08-24-2008, 08:38 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 08-24-2008, 08:51 PM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 08-24-2008, 09:06 PM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 08-24-2008, 09:19 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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?
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 08-24-2008, 10:11 PM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 08-24-2008, 10:59 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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.
Quote:
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.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 08-25-2008, 05:55 AM
Member
 
Join Date: Jul 2008
Posts: 13
Rep Power: 0
chris@gaiag.net is on a distinguished road
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. ;-)
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 08-25-2008, 03:13 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SouthWest Missouri, USA
Posts: 2,229
Rep Power: 4
Norm is on a distinguished road
Default
zip/unzip all the jar files.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display Screecast in Java Stand Alone App? JimCrowell@EMail.com AWT / Swing 0 08-05-2008 04:15 PM
Could some plz tell me how to write a stand alone quickfingers New To Java 25 06-28-2008 05:22 AM
Stand O' Food Game Proyect piachens New To Java 1 03-24-2008 06:28 PM
Launching an application from another application dynamically Java Tip Java Tips 0 02-16-2008 10:31 PM
Launching an application from another application using thread Java Tip Java Tips 0 02-16-2008 10:29 PM


All times are GMT +2. The time now is 04:52 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org