NOTE : - THIS IS NOT THE ORIGINAL CONTENT
Java Authoring Info
ava is a modern, platform independent programming language that is object-oriented for reusability of code modules. This page explains why one would use Java (with a few cautions), how one can install the Development Kit (JDK), and provides simple test applications and applets to make sure everything you need is ready. Links are provided to tutorials and code samples for those who prefer to roll their own utilities or adapt other's projects. I have also included my own Java tutorials complete with suggested projects that reinforce the material presented.
Why Use Java
Why should one use Java as an authoring language?
- Modern concepts such as object oriented programming can be rolled over into other languages
- Java is easy to learn as no user programmed memory management or pointers are involved
- Java is open source and may be modified by any user to his requirements.
- Java applications and applets are platform independent
- Java is robust, learning from mistakes of older languages
- Java is security conscious and enforces it through a virtual machine paradigm
- Java is complete, and many complex projects such as JEdit [a syntax aware editor]
and Alice [a 3D programming language] have been developed in Java.
Cautionary Notes
Do not believe documentation. Test for yourself. Even sun.com makes errors as it does in the System.in.read() method. Keystrokes are read as integers, not characters.
Be prepared to test Java applets with at least two versions of each of the major browsers. Remember that there are also browsers that have no Java support whatsoever and that some users turn Java OFF by choice. This is not a Java problem but one of browser conformance to the w3.org recommendations. The situation is improving however!
Installing the Java Developer's Kit
Sun MicroSystems designed and developed Java and control the 'essence' of the language. The current version of the Java Development Kit is JDK 6-Update 13. Those with older operating systems may need to consult the archives. If you want to use the Java visual 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: MicroSoft Visual Studio, DrJava, Eclipse, JBuilder and JCreator.
Note: Although some programmers find using an Interactive Development Environment (IDE) helpful in larger projects, many find learning the IDE confuses them with learning Java itself. A basic text editor is sufficient for Java. Use the method that you are comfortable with.
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.
Wintel User Note: The system environment variable path will have to be set within AUTOEXEC to point at the Java binary file installation directories.
| MSDOS: | EDIT Autoexec.bat |
|---|---|
| Windows 9x: | Start -- Run -- Sysedit |
| Windows XP: | Start - Settings - Control Panel - System - Advanced - Environment Variables |
You may want to create a classroom or playground folder for your project java class files that need access from anywhere. Add this folder name to the classpath system environment variable. Note: Make sure the classpath string starts with .; so that the current directory is searched before other directories are.
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
/* The HelloWorldApp class implements an application that * displays "Hello World!" to the standard output device. */ public class HelloWorldApp { public static void main(String args[]) { // Display "Hello World!" System.out.println("Hello World!"); } }
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
/* The HelloWorld class implements an applet that * displays "Hello World!" within an html document.*/ import java.awt.*; import java.applet.*; public class HelloWorld extends Applet { public void init() // Initialize canvas { Color lightgray=new Color(211,211,211); // customize setBackground(lightgray); // make mellow background resize(250,50); } public void paint(Graphics g) // Display "Hello World!" { g.drawString("Hello World!",60,25); } }
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 statingNot 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:
- Create a new folder that will contain the fileGrab utility and the tutorial material.
- Move into the folder and download the network utilities zip file [12 kb]
- Unzip the files named fileGrab.java and fileGrab.bat
- Compile the application using the command javac fileGrab.java.
- Download javapack.lst, the current list of tutorial files to be downloaded for off-line viewing.
- Run the application using the command fileGrab.bat.
- Use your browser to test that all the files are ready to use offline. The root file is jaintro.htm (this page)
Tutorials and Code Samples
The following sites provide tutorial material for Java. Combined with good textbooks, all the required topics should be well covered. Sun also provides a Coding Conventions document to help standardize your work.
|
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
Why should you create code to do something if someone else has already written it? There are many finished Java programs and utilities that are ready-to-run. The following sites may already have the functions you want and probably many more that you didn't even think about. Spend some quality time trolling for ideas!
|
|
Most of these projects are packaged in JAR (Java Archived Resource) files which are similar to zipped packages in Windows. To unpackage a .jar file you use the commands:
- java -jar file_name.jar
- jar -x file_name.jar. If you just want to view the contents first, use the -tf option instead of -x.
BIBLIOGRAPHY / REFERENCE : -
FOR REFERENCE....PLEASE VISIT :

No comments:
Post a Comment