Get your CodeRanch badge!*
The moose likes Beginning Java and the fly likes Java executable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java executable" Watch "Java executable" New topic
Author

Java executable

Kasun Liyanage
Greenhorn

Joined: Mar 09, 2011
Posts: 23

Hi!

Is it possible to make a Java executable file from a Netbeans project? i mean, a file which i can double click and run.

Thanks.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18117
    
  39

Kasun Liyanage wrote: i mean, a file which i can double click and run.


Most OSes, if configured, will run executable jar files upon a double-click.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Edwin Torres
Ranch Hand

Joined: Mar 19, 2011
Posts: 37
Yes. When you build a Netbeans Java Application, it creates a .jar file. As long as you have the Java Runtime Environment installed on your OS, you can run the .jar file by double-clicking it or running it from the command line: java -jar myapp.jar


Follow me: @CompGuyProbs
Read me: Freehold Computers Examiner
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Also, as long as the NetBeans project being built has a main class set, and that class has a public static void main(String[] args) method.


luck, db
There are no new questions, but there may be new answers.
Kasun Liyanage
Greenhorn

Joined: Mar 09, 2011
Posts: 23

Thanks for the replies! i set the jar as an executable in Ubuntu and used Executer to convert jar file in to an exe in Windows. And it works, thanks.
Atul Darne
Ranch Hand

Joined: Jul 05, 2009
Posts: 118

set your class path and the path to the jar through a .cmd file in windows


Regards, Atul.
I came to this world on a Learner's License
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36486
    
  16
Atul Darne wrote:set your class path and the path to the jar through a .cmd file in windows
Is that necessary? As long as the file association for .jar is the same as your javaw runtime, it should work. Note you usually use javaw for executable .jars, not "java".
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Henry Wong wrote:
Kasun Liyanage wrote: i mean, a file which i can double click and run.


Most OSes, if configured, will run executable jar files upon a double-click.

Henry


How to configure an OS to do that, say windows 7 (mine is already configured but fails to open some jars).


SCJP 6. Learning more now.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Well, the jar does have to be an executable jar.
http://download.oracle.com/javase/tutorial/deployment/jar/appman.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java executable
 
Similar Threads
make executable in java
How To Compile Using Command Line
.jar or .exe
creating win exe file from java
Java executable file