iSelfSchooling.com  Since 1999     References  |  Search more  | Oracle Syntax  | Free Online Oracle Training

    Home      .Services     Login       Start Learning     Certification      .                 .Share your BELIEF(s)...

 

. Online Accounting        .Copyright & User Agreement   |
    .Vision      .Biography     .Acknowledgement

.Contact Us      .Comments/Suggestions       Email2aFriend    |

 

JAVA for Oracle Developers

Basic Steps to write, compile, and run a JAVA application

 

 

Gathered By: John Kazerooni

How to install JAVA on my machine?

JAVA development tool is free. If you don’t have it, you can download it now from the “DownLoad JAVA” link. Download the latest release to your desktop. Double click on the downloaded icon on the desktop and follow the instructions. Use the default folder, select components that you need (all), and define your default browser. That is all! Don’t forget to view and read the README file. . (Make sure you download the SDK, not the JRE.)

 

How to write a JAVA application?

A JAVA application is a standalone program.

Let us write a JAVA application to display the “I will be a self learner!” message.

 

Step #1: Write and Create a JAVA source file

Use the notepad editor.  Write, your first program, IamSelfLeaner, to display the “I am self learner!” message as a JAVA application program.

Then save your application program as “c:\IamSelfLeaner.java” within the double quote and exit from notepad. Be careful what you type. The JAVA compiler and interpreter are very case-sensitive.

 

Notice that the bold characters in the following listing are comments.

 

/******************************************************

 * The IamSelfLeaner class implements an application that

 * displays the "I am a self leaner!" message to the standard output.

 ******************************************************/

public class IamSelfLearner {

    public static void main(String[] args) {

        // Display "I am a self learner!"

        System.out.println("I am a self learner!");

    }

}

 

A closer look at your program:

 

The Java language supports three kinds of comments:

/* text */  -- It means the compiler ignores everything from /* to */.

/** documentation */  -- Just like /* text */ and the JDK javadoc uses it to generate documents.

// text  -- It means that the compiler ignores everything from // to the end of the line.

 

A “class” is a template that describes the object and its behavior. You create an object by instantiating it to a class. Its data is stored in variables and its behavior is implemented with methods. Think of a method like stored procedures in Oracle.

 

A main is a method and it is the entry point of every Java application. When you run an application with the Java interpreter, you specify the name of the class that you want to run. The interpreter invokes the main method defined within that class. The main method controls the flow of the program, allocates whatever resources are needed, and runs any other methods that provide the functionality for the application. If your application does not have a main method, the interpreter refuses to run it and displays an error message. The main method may accept arguments

 

public” is the easiest access specifier. Any class, in any package, has access to a class's public members. Declare public members only if such access can be seen by outsiders.

The following chart shows the access level permitted by each specifier.

Specifier

class

subclass

package

world

private

X

 

 

 

protected

X

X*

X

 

public

X

X

X

X

package

X

 

X

 

 

Variables and Methods can be referred by join the class name and the name of the class method or class variable together with a period ("."). See System.out.println.

 

Step #2: Compile your source program

Go to the MS-DOS or Command prompt and change your current directory to the directory where you saved the JAVA source program. Remember that the JAVA compiler be in your path. If it is not, then set the path (set PATH=your java path/bin).

 

Example: MS-DOS> c:\java folder\bin\javac IamSelfLearner.java

If there are no errors, then you have successfully compiled your program. Now, you have generated a JAVA bytecode file, IamSelfLearner.class. Now that you have the class file (a JAVA bytecode file), you can run your program. This file can run anywhere. That means that when you compile your program, you don't generate instructions for one specific platform. They are instructions for the Java Virtual Machine (Java VM).

 

Step #3: Run the Program

In the same directory, enter at the prompt type the following.

MS-DOS>java IamSelfLearner

And now you should see:  I am a self learner!

 

If you got the “I am a self learner” message then your program works. Congratulations!

If not, then make sure that your are in the “class” folder or you might have to change your CLASSPATH variable (set CLASSPATH=).

 

Google
 
Web web site