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!

Dani AI

Generated

and are asking the right first question: applet or application? In 2025, applets are effectively gone. Oracle removed the old browser deployment stack (plugin, appletviewer, Web Start) in JDK 11, and the Applet API itself is now being removed from the platform, so there is no supported way to run applets in modern Java or browsers. If you have legacy JNLP files, use OpenWebStart (a community reimplementation of Java Web Start). Otherwise, convert your code to a normal desktop application. See Oracle’s JDK 11 notes and the OpenJDK proposal for context, and OpenWebStart for JNLP. Oracle JDK 11 notes. OpenJDK: Remove the Applet API. OpenWebStart.

For double‑click launching, is spot on that BlueJ is just an IDE. Package your compiled classes into an executable JAR with a manifest that names your entry point. Minimal example:

# Manifest.txt (must end with a newline)
Main-Class: com.example.Main

Then create the jar (from the directory containing your compiled classes):

jar cfm MyApp.jar Manifest.txt -C out/classes .

Windows/macOS will typically launch that JAR on double‑click if Java is installed. Details and alternatives for setting Main-Class are in the Oracle tutorial. Oracle tutorial: set Main-Class. jar tool reference.

If you want a native icon/installer (no separate Java required), use jpackage to build a Windows .exe/.msi or a macOS .dmg; build each on its target OS. This is a cleaner, cross‑user alternative to the batch file suggested. jpackage docs.

Recommended Answers

All 4 Replies

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)

Mitch

commented: thanks this is exactly what i was looking for :) +3

click the "solved" button if this thread is solved (for you :) )

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.