Results 1 to 12 of 12
- 04-22-2009, 06:35 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 17
- Rep Power
- 0
Executing JAR File by double clicking
Hai,
I created one program using NetBeans.
To use NetBeans, there is no need set the class path.
DataBase connectivity, we just add the DBConnection jar file for that.
NetBeans itself create the JAR file for our program. If i put that Project jar file, in any other system,
Is it possible to run the program, by double clicking it?
Thanks in advance.
- 04-22-2009, 07:04 AM #2
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
You need to create an executable jar. To do this manually, you create a manifest file. Create a file called, say, manifest.txt that contains a line such as:
Main-Class: com.mypackage.MyMainClass
then when you package up your Jar, you add an -m switch to the jar command, giving the name of the manifest file.
I'm guessing NetBeans has some friendlier way to ad a "manifest file", but that's probably what you're looking for.
Now, whether a particular system decides to launch the jar when a user double-clicked on it is system-dependent. It works on Windows, though, which covers most of the user base not used to using a command line.Neil Coffey
Javamex - Java tutorials and performance info
- 04-22-2009, 08:09 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 17
- Rep Power
- 0
Thanks for your reply,
If i double that jar file, it is opening the interface. But DB connection is not working, through this.
But if i execute the project, through NetBeans.. It is working fine.
- 04-22-2009, 08:10 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
NetBeans does all of this by itself, automatically, per default. Including the classpath references to the external jars and places those jars in a lib directory that sits in the same directory as the original jar so everything is ready to be packed up and deployed by simply taking the entire "dist" directory.
But you have take the entire contents of the "dist" directory, not just the application jarfile.
- 04-22-2009, 09:11 AM #5
Member
- Join Date
- Apr 2009
- Posts
- 17
- Rep Power
- 0
Thanks for your reply...
Its perfectly working in some system , if i put that dist folder.
Some machine, if i double click , no action is happening....
- 04-22-2009, 09:29 AM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Well, "no action is happening", doesn't help, to tell you the truth.
Open a command prompt and type
Java Code:java -jar /full/path/to/jarfile.jar
- 04-22-2009, 09:35 AM #7
Member
- Join Date
- Apr 2009
- Posts
- 17
- Rep Power
- 0
It is working in Command prompt.
If i double click that jar file, it is not working..
- 04-22-2009, 10:34 AM #8
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Then what do you mean by "some systems"? By specific OSes (I.E. Solaris/Windows) or by specific computers even though it is the same OS?
In any case, if it "works" on that system from the command line, then the problem is not (at least not solely) Java related, but is rather system related. Either faulty file associations or some other system item, but no longer, per se, a Java problem.
- 04-22-2009, 11:17 AM #9
Member
- Join Date
- Apr 2009
- Posts
- 17
- Rep Power
- 0
Window os only.
All systems are Windows xp.
Help me to debug this kind of issue....
- 04-22-2009, 11:37 AM #10
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Well, as long as you file associations are set properly (and the user doing the "clicking" has access to the jarfile) then "double-clicking" that jarfile does exactly what you did in the command line. All you can do is to check your file associations and file access permissions.
- 04-22-2009, 11:45 AM #11
Member
- Join Date
- Apr 2009
- Posts
- 17
- Rep Power
- 0
Thanks for your reply,
I dont know, how to check file associations and file access permissions?
Can you assist me?
- 04-22-2009, 12:51 PM #12
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 8
Google?
windows file associations
How to change or select which program starts when you double-click a file in Windows XP
File association - Wikipedia, the free encyclopedia
windows file permissions
How to set, view, change, or remove special permissions for files and folders in Windows XP
File system permissions - Wikipedia, the free encyclopedia
Similar Threads
-
Executing a jar double-click style in Linux
By goodwillwins in forum AWT / SwingReplies: 24Last Post: 03-19-2011, 04:56 AM -
Double clicking executables jar files?
By cruxblack in forum New To JavaReplies: 6Last Post: 04-23-2009, 02:00 AM -
[SOLVED] Error executing Jar file
By VeasMKII in forum New To JavaReplies: 3Last Post: 01-31-2009, 05:32 AM -
executing the java file
By TheBayWatchMan in forum New To JavaReplies: 4Last Post: 01-12-2008, 09:31 AM -
Executing a jar file
By peiceonly in forum New To JavaReplies: 2Last Post: 04-06-2007, 02:32 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks