How to Run Java Applet Program with New Versions of Java

If you have tried to run a Java applet program using your latest version of Java (later versions from Java SE 11 released on September 2018), you will have some errors because those versions from Java SE 11 don't support web Start applications or applets.


Even if you have an old version of Java with applet. Your browser will show show an error because Firefox and Chrome no longer support applets.

Older versions of Java had appletviewer to run applets. 


So How can you run Java applets if the browsers and latest versions of Java don't support them?



The appletviewer command allows you to run Java applet without a browser. But for the appletviewer command to work you need to install the older version of Java in your  PC.

So the doubt you have will be having will be what if you have the latest version of Java installed on your PC and don't want to replace it with an older version.

So the option we have is to have two versions of Java installed on your PC. To compile your applet program you need to use the older version and for all other Java programs you can use the new version you already have.

So you need to have multiple versions of Java installed on your computer.


Steps to run your Java applet using the older version of Java.





  • Extract the download rar file to the same location where the Java is installed on your PC. By default the location is C:\Program Files\Java . Now you will have two versions of Java on your PC.


  • Next you need to do some file renaming.
Inside the folder jdk-9.0.1. Open bin folder.

Rename the executable file javac to javacold.
Rename application java to javaold.

  • Set path for old version.
Copy the address of bin folder, by default C:\Program Files\Java\jdk-9.0.1\bin.

Right click on This PC, Go to properties.
Click on Advanced system settings. Select Environment Variables.
Select Path under System Variables and click edit.
Click New and paste the address of bin folder we had copied (C:\Program Files\Java\jdk-9.0.1\bin)
Click OK on all opened windows to This PC properties.


  • Now let's test if we can run a Java applet program
Create HelloWorld.java file which is a Hello World applet program.

HelloWorld.java


Make sure that you have the HTML part as a comment in your code itself like in the program given above.

Compile the program in your terminal using javacold command.

javacold HelloWorld.java

After compilation you will get a message. Then run the applet using the command appletviewer.

appletviewer HelloWorld.java

Now you can see the Hello world applet running.


Conclusion


Java applet is not supported by Java as well as the browsers. So we need to use appletviewer command of older versions of Java to run an applet program.

I hope this post helped you to run your applet program successfully on your PC. If there is any questions or feed backs hit me up in the comments.


Jobin Jose

12 comments:

  1. thank you so much, it was of great help

    ReplyDelete
  2. Thanks. By following this i have really solve my problem

    ReplyDelete
  3. did this as mentioned in the instructions, even got the applet to display HelloWorld.java
    This is whats being shown when trying to run other applet based programs:
    Warning: Applet API and AppletViewer are deprecated.
    .
    any way to get around this?
    Thanks

    ReplyDelete
    Replies
    1. you can ignore the warning and go ahead with the appletviewer command

      Delete
    2. thank you so much..I was jumbled after seeing the warning but now I realize that you have to ignore some exceptions in your life in order to succeed.

      Delete
  4. thanks aloads this helped me going through my applet codes....really appreciate your effort

    ReplyDelete
  5. thank you.... my dear friend...
    keep going rock...

    ReplyDelete
  6. sir i trying but not appletviewer is not run

    ReplyDelete
  7. "This blog post on spray bottle deserves a round of applause. It's evident that a lot of research and effort went into creating such a comprehensive guide. I'm grateful for the valuable insights shared here, and I'll definitely be implementing your recommendations. Well done!"

    ReplyDelete