How to compile Java class with Command Prompt?
1.Create New Folder on your hard drive
Ex: I create new folder name "Test_Java" on drive c:
2.Open any Text Editor for create Java class. you can use notepad++ it's free and has high light code feature....
Ex: type this codes in your text editor
class TestJava {
public static void main (String arg[]) {
System.out.println("Hello" + arg[0]);
int a = Integer.parseIn (arg [1]);
int b = Integer.parseIn (arg [2]);
if ((a<0) && (a>b/0))
System.out.println ("No Display...!");
else
System.out.println ("No Error...!");
}
}
3.Save your code with extension *.java in your directory ("Test_Java") that you created.
Ex: I save it JTest.java
4.Run Command Prompt by Type "cmd" in run on start Menu
5.In Command Prompt:
-Type cd\ for back to first directory
-Type cd C:
Ex: C:\
-Type your directory name "Test_Java" and Hit Enter
Ex: C:\cd Test_Java
-Type Path after your directory name then space and Type directory of "bin" (Java Development kit) hit Enter again.
Ex: C:\Test_Java\Path C:\Program Files\Java\jdk1.6.0_01\bin
-Type "javac" space "Your file java" and Enter
Ex: C:\Test_Java\javac JTest.java
-If you do right it will create class of your java file in current directory
Ex: now TestJava.class in my directory
-Type "java"space "Your Java class name" "arg[0]" "arg[1]" "arg[2]" hit Enter
Ex: C:\Test_Java\java TestJava "everybody" "10" "0"
-Now you can see the result.....!
Ex: Hello everybody
No Error...!
*Note:
jdk1.6.0_01 directory is create when we install jdk-6u1-windows-i586-p.exe (Java Development kit). Or you can download it here:
http://java.sun.com/javase/downloads/index.jsp
Download notepad++ here:
http://notepad-plus-plus.org/download
............


No comments:
Post a Comment