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

No comments:

Post a Comment