Skip to content

rednaxelafx/jvm.go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jvm.go

A JVM written in GO... jvm.go Logo

Introduction

jvm.go is a new JVM(which is far from complete) programmed in Go. The main purpose of this project is learning Go and JVM. So, the number one goal of the project is readability of code. The basic idea is just implement the core JVM, and use rt.jar(from OpenJDK) as its class libraries. GC is directly using Go's. For me, the hardest part is Thread and ClassLoader.

My dev environment:

  • Mac OS X 10.10.2
  • Java 1.8.0_31
  • Go 1.4

Build jvm.go

go get github.com/zxh0/jvm.go/jvmgo

Run jvm.go

Create the following folder and file structure:

$GOPATH/bin
├── jvmgo
└── jre/
    └── lib/
        ├── rt.jar
        ├── currency.data
        └── net.properties
jvmgo -cp path/to/jars:path/to/classes HelloWorld

Where to find rt.jar:

/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/jre/lib/rt.jar

Example

Create 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, it will generate Main.class

javac Main.java

Run with jvmgo

jvmgo Main

Output

hello world

About

A JVM written in GO...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 86.6%
  • Java 13.3%
  • JavaScript 0.1%