Skip to content

Discussion: Compiling and running with newer versions of Java #3

@ggliv

Description

@ggliv

Dr. Cotterell started a discussion on running the project with later versions of Java here.

I tried to reproduce the compilation issues mentioned in that comment using Java 17 on my machine and was unable to get the same errors. Here's my Java version:

$ java -version
openjdk version "17.0.15" 2025-04-15
OpenJDK Runtime Environment (build 17.0.15+6)
OpenJDK 64-Bit Server VM (build 17.0.15+6, mixed mode, sharing)

Here's what I get trying to compile with the provided command:

$ /usr/lib/jvm/java-17-openjdk/bin/javac --release 8 -d .backend_classes -cp backend/cp:backend/cp/javax.json-1.0.jar backend/**/*.java
backend/cp/traceprinter/InMemory.java:39: error: cannot find symbol
    VirtualMachine vm;
    ^
  symbol:   class VirtualMachine
  location: class InMemory
backend/cp/traceprinter/InMemory.java:183: error: cannot find symbol
    VirtualMachine launchVM(String className) {
    ^
  symbol:   class VirtualMachine
  location: class InMemory
backend/cp/traceprinter/InMemory.java:267: error: cannot find symbol
    LaunchingConnector theCommandLineLaunchConnector() {
    ^
  symbol:   class LaunchingConnector
  location: class InMemory
backend/cp/traceprinter/InMemory.java:19: error: package com.sun.jdi does not exist
import com.sun.jdi.*;
^
backend/cp/traceprinter/InMemory.java:20: error: package com.sun.jdi.connect does not exist
import com.sun.jdi.connect.*;
^
backend/cp/traceprinter/JDI2JSON.java:56: error: cannot find symbol
    private VirtualMachine vm;
            ^
  symbol:   class VirtualMachine
  location: class JDI2JSON
[...]

These all seemed to come from the tools.jar library not being available. When I passed that in from a Java 8 install I also have, compilation worked fine.

$ /usr/lib/jvm/java-17-openjdk/bin/javac --release 8 -d .backend_classes -cp backend/cp:backend/cp/javax.json-1.0.jar:/usr/lib/jvm/java-8-openjdk/lib/tools.jar backend/**/*.java
Note: backend/cp/traceprinter/ramtools/RAMRun.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

I could then run this with Java 17 using /usr/lib/jvm/java-17-openjdk/bin/java -cp .backend_classes:backend/cp:backend/cp/javax.json-1.0.jar:/usr/lib/jvm/java-8-openjdk/lib/tools.jar traceprinter.InMemory. This worked fine.

It appears that the tools.jar library was removed in Java 9 and most of its functionality was incorporated into the java.compiler built-in package. That package isn't a drop-in replacement though. If we wanted to prioritize making Java 17 our target platform, we might be able to rewrite portions of traceprinter to use this new package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions