2

Can someone please show me how I can use/install a java applet I downloaded to work with my browser (firefox). The applet is BNCApplet.java that I got from this link:

http://world.std.com/~reinhold/BigNumCalc.html

I have installed openjdk using:

sudo apt-get install openjdk-8-jdk

And tried to compile by:

javac BNCApplet.java

which gave me loads of error messages that mean nothing to me. Here it is:

javac BNCApplet1.java 

BNCApplet1.java:51: error: class BigNumCalc is public, should be
declared in a file named BigNumCalc.java public class BigNumCalc 
       ^ Note: BNCApplet1.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note:
BNCApplet1.java uses unchecked or unsafe operations. Note: Recompile
with -Xlint:unchecked for details. 1 error

I am sure this java program is bug-free and should work flawlessly. In any case should I be compiling this at all before I can use it as a plugin? And how do I use it as a plugin.

Update: I have also installed icedtea as suggested by Byte Commander:

sudo apt-get install icedtea-8-plugin

and checked it in firefox preferences and it is there and active.

When I File/Open the BNCApplet.java in firefox it simply offers to save the file!

I badly need a step-by-step insrtructions to install this applet. Thanks

1 Answers1

0

A .java file is a Java source code file, which is a plain text document. It is not executable.

To run it, you would have to install a JDK (Java Development Kit) like the openjdk-8-jdk package, if you don't have one already:

sudo apt-get install openjdk-8-jdk

After that, you can use the Java compiler javac to compile the source code BNCApplet.java file to a byte code .class file:

javac BNCApplet.java

After that, you can run the compiled BNCApplet.class file using the java command, but without the .class suffix:

java BNCApplet

Further reads about how to compile and run .java files on Ubuntu:


I'm not 100% sure, but this way Applets should run in a separate Applet Viewer window. To be able to run Java Applets in your browser if you use an OpenJDK Java implementation, you need the additional IcedTea package that provides a browser plug-in for Firefox-like (NPAPI) browsers. Oracle Java already includes this plug-in.

To install the plug-in for OpenJDK 8, run:

sudo apt-get install icedtea-8-plugin
Byte Commander
  • 107,489
  • I installed openjdk as you suggested and tried compiling -- this is how it went: $ javac BNCApplet.java BNCApplet.java:8: error: unmappable character for encoding UTF8 Copyright � 2000 Arnold G. Reinhold, Cambridge. MA USA ^ 1 error -- (the hat sign points to the character before 2000) –  Oct 22 '16 at 16:03
  • Please edit your questions to provide this information, comments are not well suited for output, as they don't preserve formatting. They also might be deleted for several reasons. And the issue you're pointing out has something to do with the character encoding of the Java source code. The easiest fix would probably be to to open the file in a text editor and remove that offending character, probably it's a © somewhere in a comment line or in a string, which shouldn't affect the program. – Byte Commander Oct 22 '16 at 16:52