What causes this jAnsi NoClassDefFoundError?

1.8k Views Asked by At

In my code i am using the jAnsi Libary. but it spits the following error:

import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.Ansi;



public class SnakeGame {


public static void main(String[] args) {        
    
    AnsiConsole.systemInstall();
    System.out.println( 
    Ansi.ansi().eraseScreen().fg(Ansi.Color.RED).a("Hello").fg(Ansi.Color.GREEN).a(" 
    World").reset() );
    AnsiConsole.systemUninstall();
    }
}

i already tried this PlayFramework 2.3.1 NoClassDefFoundError: org/fusesource/jansi/AnsiOutputStream and it doesnt apply to my problem

Here is the Error it spits:

Exception in thread "main" java.lang.NoClassDefFoundError: org/fusesource/jansi/AnsiConsole at SnakeGame.main(SnakeGame.java:11) Caused by: java.lang.ClassNotFoundException: org.fusesource.jansi.AnsiConsole at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 1 more

i tried using Versions 2.10 and 2.01, but the problem stays.

Do you have any Idea how to solve this?

or should i just use another language than java. because i already tried jLine and it doesent work either.switching language would be the last option for me.

gg Guys,

kind regards,

Alwin

1

There are 1 best solutions below

0
On

To compile

javac -cp path/to/jansi.jar SnakeGame.java

To run

java -cp path/to/jansi.jar:./ SnakeGame

Alternatively you can export the CLASS_PATH env variable and do them normally