Java Applets are useful on a web page or web site to do things which may not be possible using HTML or Javascript (but keep in mind that not all computers include a Java environment). To build Java applets, you need a Java Compiler (javac), and to compress the applet(s) into a nice neat package, you also need a Java Archiver (jar).
This web page shows you how to install SUN's JDK (Java Development Kit) so that you can use it even if your favorite Linux Distro already comes with an existing Java compiler.
If your Linux Distro already includes a Java compiler and you have no interest in installing or using the SUN compiler, then you can skip this web page.
The following 3 example pages show you how you can make Java Applets on the command line or by using scripts.
DOWNLOAD THE SUN JDK (JAVA DEVELOPMENT KIT)
To begin, you need to get the JDK package and download it to your Desktop. Just go to the Java JDK website and select the JDK (this How-To will install jdk-6u7-linux-i586.bin).
NOTE: You will notice on the download web page that there is an RPM and a non-RPM version for Linux. Even if your Linux Distro is capable of using RPM based packages, this How-To uses the non-RPM version to have more control over the placement location so that it does not conflict with your existing setup (if you have one already).
1. 2. 3. |
|
1. 2. 3. |
|
MAKE SCRIPTS TO COMPILE YOUR JAVA
As you can see above, not many steps were used to install the SUN JDK. This allows you to use the SUN JDK even if your Linux install already comes with a Java Compiler.
If your Linux Distro already has an existing Java Compiler and you want to build Java applets using the compiler that came with your Linux Distribution, then follow the steps shown on the following example pages.
If you want to build Java applets using the SUN JDK, then you need to also insert 3 additional "export" lines and use scripts only because you need the exported information. The example shown below shows you the clock script with the additional "export" information required to compile Java programs. Please modify the "export" info to match your choice of JDK toolkit location and the version you downloaded.
| #!/bin/sh
export JAVA_HOME=/home/you/jdk1.6.0_07 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=$CLASSPATH:. cd ~/temp # Create compiled code from java file. # Create compressed jar archive from compiled file. # Cleanup results; clock.class not needed. # Show results |
| Other Java Pages On This Web Site | |||
|---|---|---|---|
| Example Clock | Example Spreadsheet | Example Rubik's Cube | A Few Games |
| Other Pages On This Web Site | |||||
|---|---|---|---|---|---|
| Home Page | Backup With Tar | Disk Image Backup | BOINC On Linux | Ship Arcade | PicDis Disassembler |