Hi everyone, I am fairly new to programming, but I was wondering if there was a way to run the java program i make when it is not in the bluej compiler (i am using bluej). I would like so that i can double click an icon and my applet runs, like the applets that you can download from the java tutorials site (in a jnlp format i believe) thanks for all your help in advance!

6 Years
Discussion Span
Last Post by NP-complete

Is your program an Applet or an application? An Applet requires a browser or Appletviewer to execute. An application needs the java command.

In both cases you put the class files into a jar file for ease of handling. For the application to be executable without knowing which class to start with, you need to put a manifest file into the jar file that the java command can read to find the starting class.
For the Applet, you need an html file with an <APPLET tag with code= and archive= attributes.
You'll probably have to read up on how to do this in the Java Tutorial.


if it is an application and not an applet, you could:

1. create a notepad .txt file.
2. rename it to something.bat
3. right click on file and select "edit"
4. type in: java (drag applet .class file here)
5. open start, run, type in cmd
6. drag something.bat into cmd window, hit enter.

Wow! It works! (hopefully :P)


thanks this is exactly what i was looking for :)

One more thing, BlueJ is NOT a compiler. Its just an IDE. The compiler is within the jdk file that you probably have downloaded from sun. To compile a .java file without blueJ is simple. First you need to set a classpath for the bin subdirectory inside your jdk directory. Instructions for the same can be found by googling "classpath" and "java".
Once you have set the classpath properly open the command prompt and move to the place where you have saved your .java file. Oh btw, you write your code in any text editor like notepad and save it as a .java file (make sure you select "all files" while saving in notepad). Say you saved it in desktop and named it MyFile.java.
In the command prompt navigate to desktop and write these command:

javac MyFile.java

this will compile your code. After that when you want to run it just simply type

java MyFile

Hope it helps.

This article has been dead for over six months. Start a new discussion instead.
Be sure to adhere to our posting rules.