I believe you come to this page because you are new to Java Programming. Before we go further you might want to know what java history.
Developed by a team led by James Gosling at Sun Mircosystems. Originally called "OAK", it was designed in 1991 for used in embedded consumer electronic applications. In 1995, renamed "JAVA", it was designed for devolving Internet applications.
Java can be embedded in HTML pages and downloaded by web browsers to bring live animation and interaction to web client. Java also not limited to web applications, it also can be used to develop standalone applications. Java is inherently object-oriented.
Do not be confuse Java and JavaScript is different.
Java:
-Java is a programming language.
-The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture.
JavaScript:
-JavaScript is an object-oriented[4] scripting language used to enable programmatic access to objects within both the client application and other applications.
Things you must know and understand before run java. Your first application, HelloWorldApp, will simply display the greeting "Hello world!". To create this program, you will:
* Create a source file
A source file contains code, written in the Java programming language, that you and other programmers can understand. You can use any text editor to create and edit source files.
* Compile the source file into a .class file
The Java programming language compiler (javac) takes your source file and translates its text into instructions that the Java virtual machine can understand. The instructions contained within this file are known as bytecodes.
* Run the program
The Java application launcher tool (java) uses the Java virtual machine to run your application.
Run you first java applications.
First step is you need to install :
The Java SE Development Kit 6 (JDK 6) . Here is installation instructions.
Create a source file.
##we will use Notepad, a simple editor included with the Windows platforms##
(Start > All Program > Accessories > Notepad)
--------------------------------------------
/**
* The HelloWorld class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
-------------------------------------
save this file into your computer in a specify folder for example C:\Java
Type all code, commands, and file names exactly as shown. Both the compiler (javac) and launcher tool (java) are case-sensitive, so you must capitalize consistently.
*! class name must same the file name for our example HelloWorldApp
Compile the Source File into a .class File
Bring up a shell, or "command," window. You can do this from the Start menu by choosing Command Prompt (Windows XP), or by choosing Run... and then entering cmd. The shell window should look similar to the following figure.
Now the prompt should change to C:\java>.
!* use "DIR" to see all file in java folder.
Now you are ready to compile. At the prompt, type the following command and press Enter.
javac HelloWorldApp.java
Run the Program
In the same directory, enter the following command at the prompt:
java HelloWorldApp
The next figure shows what you should now see:
Congratulations! Your program works!
Important
You might have a problem during creating .class file and the error should like as below:"javac is not an internal or external command operable
statement or batch file".
solutions :
Add it to your path or reinstall it properly.
C> javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.
C> set PATH=%PATH%;C:\Program Files\Java\jdk1.6.0_02\bin
C> javac -version
javac 1.6.0_02
another tips :)
you can drag your file into javac.exe to create .class file.
javac.exe can found in "C:\Program Files\Java\jdk1.6.0_18\bin"
you can create shortcut into your desktop. Again just drag your .java file into this javac.exe.
3 comments:
Atukkk... susaaa... :D
tidak juga bah.. senang jak tu
nice post.step by step guide
Post a Comment