Skip to content

Latest commit

 

History

History
74 lines (50 loc) · 3.1 KB

README.md

File metadata and controls

74 lines (50 loc) · 3.1 KB

RingJava

RingJava is a package for the Ring programming language that enables developers to use Java classes and methods directly from Ring. The package hosts the Java virtual machine (JVM) inside the Ring process (JNI invocation API) and talks to it through a small Java bridge. The Java class library (java.base, java.sql, java.xml, java.desktop with AWT and Swing, java.net.http, java.logging ...), and any jar of your own or from the Java ecosystem, can be used from Ring with the same simple syntax.

Install

ringpm install ringjava from ringpackages

Example

load "java.ring"

using {
	"java.lang"
	"java.util"
}

? Math.max(3,9)                           # 9: a static method

oSB = new StringBuilder("Hello")
oSB.append(", Ring!")
? oSB.toString()                                # Hello, Ring!
? oSB.length()                                  # 12

oList = new ArrayList
oList.add("pear")
oList.add("apple")
Collections = new Collections
Collections.sort(oList)
? oList.toString()                              # [apple, pear]

oList.sort("byLength")                          # Ring code that Java runs

func byLength aArgs
	return len(aArgs[1]) - len(aArgs[2])

Architecture

RingJava architecture: your Ring program, javalib (Ring code), ring_java (C, JNI), ringjava.jar (Java), the Java class library

What is in the package

Folder Content
extensions/ringjava the C extension ring_java.c and the Java bridge (java/ringjava/*.java) with the build scripts
libraries/javalib the Ring library and generated/: the Ring classes of 181 Java packages (4,100+ classes, 233,000 lines)
bin/ ring_java.dll, ringjava.jar, load/java.ring (what load "java.ring" finds)
tools/javatools the generator GenRing.java and its manifest, and checkgenerated.ring
samples/UsingJava introduction (short programs), gui (windows), ecosystem (Maven packages, JDBC, JavaFX), tutorials (28 lessons), applications (47 programs) and tests (the automated tests)
docs/src the manual in Markdown
docs docproject.ring and the built manual in docs/site (index.html, pdf/RingJava-documentation.pdf); rebuild with cd docs; ringdoc build; ringdoc pdf

Applications

The package comes with many samples and applications:

RingJava applications: Address book, Analog clock, ASCII table, BMI calculator, Calculator, Calendar, Color mixer, Countdown, Dice roller, Eight queens, Epoch time, Expense tracker, Fifteen puzzle, File explorer, 2048

RingJava applications: Game of Life, Hangman, Image viewer, Julian day, Lights Out, Loan calculator, Log analyzer, Login form, Memory, Minesweeper, Notepad, Number guess, Paint board, Password generator, Pong

RingJava applications: Rock paper scissors, Sales explorer, Snake, Sokoban, Stopwatch, Sudoku, Temperature converter, Tetris, Tic-tac-toe, To-do list, Towers of Hanoi, Typing quiz, Unit converter, Web dashboard, Word counter

License

MIT License.