Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Wednesday, November 21, 2007

how to Compile a Java code

import java.io.IOException;

import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;

public class JDK6FirstCompile {
public static void main(String args[]) throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
int results = compiler.run(null, null, null, "Foo.java");
System.out.println("Success: " + (results == 0));
}
}

// File: MyClass.java
class MyClass {
public static void main(String args[]) {
System.out.println("Hello, World");
}
}

No comments: