Open In App

How to Install Java Applet Viewer on Linux?

Improve
Improve
Like Article
Like
Save
Share
Report

Applet viewer is a command-line program to run a java applet. It helps you to test an applet before you run it in the browser. The applet’s code gets transferred to the system & then the Java Virtual Machine (JVM) of the browser & executes that code.

In this article, we will look into the process of installing a Java Applet Viewer on Linux.

Installing Java Applet Viewer on Linux:

Follow the below steps to install Java Applet Viewer on Linux:

Step 1: For installing Java Applet Viewer, you need to first download Java JDK 8. Because Java gives applet only up to JDK version 9 only.

Step 2: Open Terminal and execute the below command:

 sudo apt install openjdk-8-jdk openjdk-8-jre 

This command will install Java JDK 8. Or if you already installed it, it will give the following output.

Installing Java Applet Viewer on Linux

Step 3: Write a sample applet code. You can write the following code also. Save it by the name Demo.java in a folder which name is also Java.

Java




import java.awt.*;
import java.applet.*;
 
public class Demo extends Applet
{
  public void init()
  {
        setForeground(Color.white);
        setBackground(Color.blue);
  }
  public void paint(Graphics g)
  {
    g.drawString("Welcome To Java Applet",40,50);
  }
}


Step 4: Write the following commands one by one to execute the applet program.

cd Java/
ls
Demo.class Demo.java
javac Demo.java
appletviewer Demo.java

change directory to the .java file

Step 5: As a result, the program will be executed & give output.

Hence Java Applet Viewer is successfully installed.


Last Updated : 05 Sep, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads