S
H
A
R
E

Friday, April 08, 2011

Java. Compile & Run Using Command Prompt

This a sample code, save as "app1.java":

public class app1 {
public static void main(String arg[]){
    System.out.println("Haiii haha.. \nThis Ur Java Code");
}
}


This Compiler created from cmd, save as "java_Compile&Run.cmd":

set c=C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar
echo off & cls
javac -Xbootclasspath:"%c%" -classpath . app1.java
java -Xbootclasspath:"%c%" -classpath . app1
pause
rem klampok_child@yahoo.co.id

Place app1.java & java_Compile&Run.cmd in one folder, and double click the cmd file (execute) and see it.
javac is the main java compiler, java is interprenter to running java program (byte-code).
Have problem, please read it:
>  Make sure you have jdk1.6.0_23 installed on your windows
>  Make sure you was write java code correctly (its case-sensitive)

Try it :-)

0 comments:

Post a Comment