-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Basically the JVML allows you to run real Java on your ComputerCraft computer. So you can code your computer or turtle scripts in your favourite IDE (for example Eclipse), compile it using the default java compiler (or a similar compiler) and run the bytecode (a .class or .jar file) in Minecraft!
The JVML-JIT is a continuation of the JVML of ds84182, but it is enhanced by Just-In-Time compilation (JIT), meaning that it is much faster than the JVML of ds84182 if you call one method multiple times as it doesn't always get reinterpreted but compiled once and forever.
If you compile Java code using your standard java compiler you generate so called Java bytecode. This Java bytecode is a set of instructions which are kinda like assembler, but they are not the same. This Java bytecode has to be run by a JM (Java Machine). As the most processors aren't JMs, you must emulate one by using the JVM (Java Virtual Machine). Such a JVM can be programmed for pretty much every platform, for example Linux, Windows, Mac OS or Solaris.
The JVML is a JVM for Lua in ComputerCraft, so it excecutes the Java bytecode on a lua platform. It also defines a ComputerCraft runtime library (referenced as CCRT or CCLib) replacing the normal Java Standard Library. Besides a part of the normal Java functions (and the necessary native functions) it also defines classes for interacting with the computer. Those classes are all in the cc package.
You need the following things for running code. If you don't have them, you should install them before going on.
- Minecraft instance with ComputerCraft installed
These tools are needed if you want to develop code for JVML-JIT:
- java compiler
- Java IDE, for example Eclipse (this is actually not necessary, but recommended as it makes coding much easier)
Installation is really easy. Just install grin onto your CC computer and run grin-get install Yevano/JVML-JIT
or run pastebin run NzNwtBQy
for a direct install.
If you want to upload code to Minecraft, you first have to compile it using the following command:
javac -bootclasspath jvml/CCLib/jar/cc_rt.jar MySource.java
(The -bootclasspath option replaces the java standard library with the CCLib, so you can't compile things using unimplemented methods)
If your project consists of multiple classes you have to pack them together to a runnable jar archive so they can be excecuted together.
In order to run code you just have to excecute the following command for classes:
jvml MyClass
and the following for jar archives:
jvml -jar MyJar.jar