Getting started
1. What you need#
- Ring 1.28 or later, 64 bit (the package is tested with Ring 1.29).
- A 64 bit JDK 17 or later. RingJava is tested with JDK 21 and JDK 25.
RingJava looks for the JDK in this order, and the first folder that has the JVM library (bin/server/jvm.dll on Windows, lib/server/libjvm.so on Linux) wins:
jUseJDK("C:/PL/Java/jdk-25.0.5.1")in the program, before the first Java call;- the environment variable
RINGJAVA_HOME; - the folder
jrenext toring_java.dll: a runtime made bytools/javatools/makeruntime.ring(see Installing and distributing); - the environment variable
JAVA_HOME; - the file
ringjava.cfgnext toring_java.dll: its first line is the folder of a JDK; - the
javaprogram on thePATH.
If none is found the first Java call stops with a message that says so.
On Linux the extension is built from source (sh extensions/ringjava/buildgcc.sh with JAVA_HOME set: see Installing and distributing) and Ring needs libring.so where the loader finds it, for example export LD_LIBRARY_PATH=$HOME/ring/lib. libjvm.so is loaded by ring_java from the JDK, so it is not on LD_LIBRARY_PATH. A JDK can be unpacked in the home folder (no sudo): JAVA_HOME=$HOME/jdk/jdk-21.
2. A first program#
load "java.ring"
using {
"java.lang"
}
? Math.max(3,9) # 9
oSB = new StringBuilder("Hello")
oSB.append(", Ring!")
? oSB.toString() # Hello, Ring!load "java.ring" loads the extension and the library. using { ... } names the Java packages whose classes the program uses (like import in Java): the Ring classes of the package are loaded. The JVM itself starts at the first call.
3. Without using: the dynamic API#
Every Java class can be used without a generated Ring class:
load "java.ring"
oList = jNew("java.util.ArrayList",[])
oList.callMethod("add",["Ring"])
? jStatic("java.lang.Math","max",[3,9])
? jGetStatic("java.lang.Integer","MAX_VALUE")4. Where to go next#
samples/UsingJava/introduction has short programs for each area (strings, collections, time, files, callbacks, threads, the dynamic API). Read Core concepts and Rules and limits before the first larger program.