CPUSim4.0.11 or CPUSim3.9.0 wont start

I found an app called CPU Sim and I’m interested in computer architecture and so I’ve been trying to get it to run. Whenever I fallow the readme it fails with either of these issues.

When I try running 4.0.11 with the command java -cp .:richtextfx-fat-0.6.10.jar:reactfx-2.0-MR.jar -jar CPUSim-4.0.11.jar

I get the error of: Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class java.awt.Container at cpusim.Main.main(Main.java:135)

and when I try 3.9.0 with the command java -cp CPUSim3.9.jar:jhall.jar:CPUSimHelp3.9.jar cpusim.Main

I get the error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 
    Can't load library: /usr/lib/jvm/java-11-openjdk-amd64/lib/libawt_xawt.so
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2638)
    at java.base/java.lang.Runtime.load0(Runtime.java:768)
    at java.base/java.lang.System.load(System.java:1854)
    at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
    at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2450)
    at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2506)
    at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2705)
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2656)
    at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)
    at java.base/java.lang.System.loadLibrary(System.java:1890)
    at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1395)
    at java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1393)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1392)
    at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1425)
    at java.desktop/java.awt.Component.<clinit>(Component.java:621)
    at cpusim.Main.main(Main.java:110)

system info:

OS: linux mint 20.3
`java -version` output:
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu220.04.1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Ubuntu-0ubuntu220.04.1, mixed mode, sharing)

The issues you’re encountering with CPU Sim on Linux Mint 20.3 appear to be related to Java’s AWT library, which has dependencies on certain graphical components that may not be fully available in your environment. Here are steps to troubleshoot and potentially resolve these issues:

1. Install Required AWT Dependencies

The errors regarding libawt_xawt.so indicate missing AWT dependencies. Install the following packages to ensure your Java environment has the necessary libraries:

sudo apt update
sudo apt install openjdk-11-jdk openjdk-11-jre openjdk-11-jdk-headless
sudo apt install libxrender1 libxtst6 libxi6

2. Use Java Runtime Options

Ensure that Java is pointing to the correct libraries by specifying the X11 toolkit in your command:

For version 4.0.11, try:

java -Dawt.toolkit=sun.awt.X11.XToolkit -cp .:richtextfx-fat-0.6.10.jar:reactfx-2.0-MR.jar -jar CPUSim-4.0.11.jar

3. Run CPU Sim with Java 8 (Alternative)

Some users have reported better compatibility with Java 8. To install Java 8 and set it temporarily for CPU Sim:

  1. Install Java 8:
sudo apt install openjdk-8-jdk
  1. Run CPU Sim using Java 8:
/usr/lib/jvm/java-8-openjdk-amd64/bin/java -cp .:richtextfx-fat-0.6.10.jar:reactfx-2.0-MR.jar -jar CPUSim-4.0.11.jar

4. Confirm the Graphics Environment

Make sure your system has an active display server (X11) when running Java AWT applications. Test by running any simple GUI Java program to ensure AWT can open windows on your environment.

5. Alternative: CPU Sim Version 3.9.0 Troubleshooting

If version 3.9.0 continues to throw similar errors, try:

java -Dawt.toolkit=sun.awt.X11.XToolkit -cp CPUSim3.9.jar:jhall.jar:CPUSimHelp3.9.jar cpusim.Main

Additional Debugging Tips

  1. Check Environment Variables: Make sure that JAVA_HOME is set to the appropriate JDK path.
  2. Look for Detailed Logs: If the problem persists, adding -Djava.util.logging.ConsoleHandler.level=FINE can sometimes provide more output for debugging.

These steps should help you get closer to running CPU Sim on Linux Mint. Let me know if any additional errors appear!