jvm.go is a new JVM (which is far from complete) programmed in Go. The main purpose of this project is learning Go and the JVM. So the number one goal of the project is readability of code. The basic idea is to just implement the core JVM, and use rt.jar (from OpenJDK) as its class library. The garbage collector is implemented by directly using Go’s GC. For me, the hardest part is Thread and ClassLoader.
- Mac OS X 10.10.2
- Java 1.8.0_31
- Go 1.4
go get github.com/zxh0/jvm.go/jvmgoEnsure your Java version is 1.8.0_32 and JAVA_HOME env was set
jvmgo -XuseJavaHome -cp path/to/jars:path/to/classes HelloWorldDownload zulu1.8.0_31-8.5.0.1-macosx.zip (Zulu is a certified build of OpenJDK that is fully compliant with the Java SE standard.) and unzip it to somewhere, Copy jvmgo from $GOPATH/bin/ into unzipped folder
cd path/to/zulu1.8.0_31-8.5.0.1-macosx
jvmgo -cp path/to/jars:path/to/classes HelloWorldCreate a Java source file, Main.java:
public class Main {
public static void main(String []args){
String val = "hello world";
if(args != null && args.length > 0){
val = args[0];
}
System.out.println(val);
}
}Compile Main.java, which will generate Main.class:
javac Main.javaRun with jvmgo:
jvmgo MainOutput:
hello world