hello,

I am using netbeans and i wonder how you make a executalbe so you can drag and drop it into a floppy then run the prog on someone else's computer.

Is it call making a jar file or sommthing. ANy help is this simple or wat?

God bless.

You can't, period.

There are some tools that will create exe-wrappers but they effectively just pack an entire JVM in with the classfiles.

Create an executable Jar instead, that can then be run on any computer that has a JVM installed by either double clicking on it (if the machine is so configured) or by using the java -jar <somejar.jar> command.

Originally quoted by jwenting

Create an executable Jar instead, that can then be run on any computer that has a JVM installed by either double clicking on it

Ok, so how do u do this in netbeans? I got to here but what do i do. My program creates a window with hello world in it. I can't get it to work. This is i got so far

Attachments stuff.JPG 33.1 KB

Don't know how to do it from Netbeans. Should be mentioned in the documentation somewhere if it's possible.
If not check the JDK documentation for the jar command which tells you how to do it by hand (which you should learn to do anyway, you won't always have netbeans available).

You could create a batch file (.bat). This answer is for Windows computers. It is not an executable but it is very simple to make.

Suppose you main method is in the class MyTest. Then create a file called MyJavaRun.bat. (The name is arbitrary)

Inside the file write:

java MyTest
pause

The first line runs the JVM giving it the main class and the second command prevents the window from closing all of a sudden when the program exits.

Then just double click the .bat file and it will run the Java program.

:?: For more help, www.NeedProgrammingHelp.com

I still cannot do thuis. I follow the instructions but I create a java.content file. not a jar executealbe file? Why is this so hard. Surely someone has netbeans and has created a jar file.

:cry:

I'm trying to keep this as simple as poss... using sams teach meself java 2 in 24 minutes.

import javax.swing.*;

public class SalutonFrame extends JFrame {
  public SalutonFrame() 
  {
  super ("Salut la monde");
  setSize(350,100);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setVisible(true);
  }
  public static void main(String[] args)
  {
    SalutonFrame sal = new SalutonFrame();
  }
}

I have create a folder wit two files. one with SalutonFrame.java and one with the class properties.

How do i manifest, is tat the word, this folder and create a jar executalbe in NETBEANS

god bless

Originally quoted by server_crash

Do you know how to create one via the commandline?

No, can you show me. I just assumed it would be easier in netbeans,since it is uses a point and click interface, but I'm having noo luck.

You will have to explain it step by step. Like how to set the command prompt to the right directory. And stuff. I is very stupid. sorrie

:sad:

If this works I owe you one

He doesn't even know how to compile his sources... Read carefully.

Another victim of the IDE. Learns the tool, not the language, and gets stuck when there's no nice shiny "run" button for something.

I use netbeans too. When I am writing files, I just copy the code onto notepad and then put it on my zip drive, then when I get to the computer that I am going to use I just open up the notepad and copy the code then copy it back into netbeans. I guess it's a little complicated, but it works.

Sigh, more IDE idiocy...
And what do you do when you don't have netbeans?

Maybe you should learn to use the compiler and runtime, but of course that would mean you'd learn something and we can't have that, now can we?

Hey thanks Richard. U seem 2 no what you are on about. If you don't mind explaining to me from the start how to use java from the command line. I've never used it b4.

I guess you could say I'm:-

Originally quoted by jwenting

"...Another victim of the IDE. Learns the tool, not the language, and gets stuck when there's no nice shiny "run" button for something."

So yes,I don't know how to change the directory or how to compile and run in the command line either. So you'll have to go through that with me if you don't mind. I appreciate all the help.

To jwenting...
I prob sound stupid but we all have to start somewhere don't we? And ur right about the pitfalls associated with fancy IDEs.

:o

It's all explained in your compiler documentation and the documentation for your operating system.

It's so basic in fact that you shouldn't consider programming anything until you can use the commandline comfortably.

Iamthwee,

Netbeans uses the Apache Ant build tool to do it's compilation. The Ant build.xml file Netbeans uses should create a jar in a directory called 'dist' under the project folder.

As you know the pitfalls of using an IDE I would really recommend learning Ant. OK so it is not going right down to the command line (which is preferable) but it is a step in the right direction and will free you from the Netbeans IDE.

Apache Ant home page:

http://ant.apache.org/

The Ant Manual:

http://ant.apache.org/manual/index.html

Have fun.

Kate

As I was editing an Ant build.xml file today at work it occurred to me that although it seems easy enough, it might in fact be more difficult for a beginner to get to grips with Ant then the standard Java toolset (javac, java, jar etc ...). To that end, Iamthwee, please see below a link to the Java tools documentation.

http://java.sun.com/j2se/1.5.0/docs/tooldocs/#basic

This page will give you all the information you need to work with Java at the command line.

Kate

Yes, ANT is rather complicated. The authors have by now realised that using an XML based buildfile was probably not a good idea :) but of course it's far too late to change it.

The commandline tools are easy to use if you take a few minutes to RTFM.

First of all, tank u for everyone who has helped me.

I intend to try and get this working at the command line.
So i will have 2 read up on thsis. When i do and if i have questions i will ask.

God bless

:cool:

This article has been dead for over six months. Start a new discussion instead.