tags:

views:

114

answers:

5

I have created a Java console application using Netbeans. In the Netbeans dist directory I have the class file of the project. Now I need to give the executable files to someone else who will run them on another PC.

Which file I should send? How can he run them on his PC? Is there any way to create an exe type file?

Both PCs have the JDK installed.

+3  A: 

Build a jar file with a main class specified in it.

If he has Java installed and .jar is associated with that, he should be able to just double-click on it.

Alternatively from a command line he'd be able to run:

java -jar program.jar

There are programs around to create executable wrappers around this, but a jar file is a simpler solution in terms of packaging - it's worth trying that to start with.

Jon Skeet
A: 

In additon to Jons answer:

If you have a runnable jar to start with, it is frequently much easier to package it up in an EXE file. If you have the need search Stackoverflow for JSmooth and one-jar.

Thorbjørn Ravn Andersen
A: 

NetBeans actually answers your question. If I do a Clean/Build, the output says:

To run this application from the command line without Ant, try: java -jar "insert_your_project_name_here.jar"

Jeroen van Bergen
A: 

theres a handy page about this here:

java tools tutorial

It describes creating jar files a little further down the page

themaddhatter
+1  A: 

You can go to run menu and select clean and build project or shift+f11 after this go to dist folder in project folder and use .jar file and run that by hint say in over .

SjB