HTML Markup | JavaScript | Java | Home & Links
JR's HomePage | Updates | Site Map | Page Bottom
Why Use Java | Installing Java | Test Samples
JR's Tutorials | Readings and Code Samples

Java Authoring Info

Java is a modern, platform independent programming language that is object-oriented for code reuse. This page explains why one would use Java, how to install the Java Development Kit (JDK) and provides some simple test applications and applets to make sure everything you need is ready. Links to tutorials and code samples are given for those who prefer to roll their own utilities or adapt other's projects. Also included are my Java tutorials complete with suggested projects that reinforce the material presented.

Why Use Java

Why should one use Java as an authoring language?

Installing the Java Development Kit

Begin by selecting and downloading the appropriate Java Development Kit. The current version is JDK 6-Update 32. Those with older operating systems may need to consult the archives. If you want to use the Java visual interactive development environment (IDE), select with NetBeans instead of the basic JDK. NetBeans also allows visual layout of GUI interfaces once you have learned how to use the Swing class. Other IDEs that you may be interested in are: DrJava, Eclipse, JBuilder, JCreator and MicroSoft Visual Studio.

Note: Although some programmers use an Interactive Development Environment (IDE) in larger projects, many find learning the IDE confuses them with learning Java itself and prefer to use only a basic text editor.

Run the installer program. WARNING: Do not try to change the directory that the JDK loads into. Not all software providers are careful to make the root independent ;-[ ;-[. I came to much grief on that assumption.

Note: The environment path variable will have to be set to point at the binary file installation directories.

Note: Make sure the classpath variable starts with .; so that the current directory is searched before other directories.

You may want to create a classroom or playground folder for your project java class files that require access from anywhere. Add this folder name to the classpath environment variable.

Wintel User Note: To set environment variables use Start - Settings - Control Panel - System - Advanced - Environment Variables

Wintel User Note: NotePad will do as an editor but several features of more advanced editors are helpful. A very strongly recommended choice is TextPad which is Java aware (reserved words and punctuation are color coded) and can handle multiple files for easy cut-and-paste. If you install TextPad, be sure to place the Java quick compilation items in the tools menu by using Configure - Preferences - Tools - Add - Sdk.

Test Samples

java.com will run a check to verify that the Java Runtime Environment (JRE) has been installed correctly.

Use the following simple HelloWorld application and applet to test that the SDK development environment has been installed correctly. For a complete explanation of the code's syntax, refer to the first tutorial on Objects, Applications and Applets.

Your First Java Application

Cut and paste the above source code or type it into your favorite editor. Save the file as HelloWorldApp.java in your Java working folder (say JavaStuff, JavaTutor, sandbox, etc.).

Next compile the source file into bytecode by using the command javac HelloWorldApp.java. If an error message stating Not Found occurs, type the command javac. If there is still an error message it means that the path needs setting (see the above note on installing). If there is no error at this point then the .java file is missing or there was a typing error. Most typing errors are due to case sensitivity. In Java, UPPER and lower case ARE different.

Finally run the application with the Java interpreter by using the command Java HelloWorldApp. For a complete explanation of the code's syntax, please refer to Basic Structure of a Java Application.

Your First Java Applet

Cut and paste the above source code or type it into your favorite editor. Save the file as HelloWorld.java in your Java working folder (say JavaStuff, JavaTutor, sandbox, etc.).

Next compile the source into bytecode by using the command javac HelloWorld.java. If an error message stating Not Found occurs, type the command javac. If there is still an error message it means that the path needs setting (see the above note on installing). If there is no error at this point then the .java file is missing or there was a typing error. Most typing errors are due to case sensitivity. In Java, UPPER and lower case ARE different.

Next create an html document that includes the following in its body.

Now view the html document in your favorite browser. For a complete explanation of the applet's syntax, please refer to Basic Structure of a Java Applet.

JR's Java Tutorials

Do you want to learn more about Java programming! Do you have an applet or application that you want to write for yourself. Then get your favorite editor ready and jump into my set of tutorials on the fundamentals of Java. They include plenty of samples and projects. And if you have questions or want to provide feedback, please email me.

Note: For those who prefer to work off-line, I have created a fileGrab utility in Java that will download all Java tutorials, source code zip packages, and required supplementary files. Follow these steps to get the tutorial material:

  1. Create a new folder that will contain the fileGrab utility and the tutorial material.
  2. Move into the folder and download the network utilities zip file [12 kb]
  3. Unzip the files named fileGrab.java and fileGrab.bat
  4. Compile the application using the command javac fileGrab.java.
  5. Download javapack.lst, the current list of tutorial files to be downloaded for off-line viewing.
  6. Run the application using the command fileGrab.bat.
  7. Use your browser to test that all the files are ready to use offline. The root file is jaintro.htm (this page)

Readings and Code Samples

The following sites provide reading material for Java. Combined with some good textbooks, all the required topics should be well covered. Sun also provides a Coding Conventions document to help standardize your work.

Many larger projects are packaged in JAR (Java Archived Resource) files which are similar to zipped packages in Windows. For information on JAR refer to the jar tutorial topic.

Java technologies can be used to create applications and applets with rich client interfaces that are secure, portable high-performance and run on multiple operating systems. The JavaDesktop community of java.net provides the latest news and information for developers of client applications for the J2SE platform. Don't miss the news, features, forums and projects at java.sun.com


JR's HomePage | Comments [jaintro.htm:2012 05 23]