Closed ajh123 closed 3 years ago
when i run java -jar myjar.jar i get
java -jar myjar.jar
Error: Unable to initialize main class path.to.my.Main Caused by: java.lang.NoClassDefFoundError: com/googlecode/lanterna/screen/Screen
My MANIFEST.MF
Main-Class: path.to.my.Main
And here is my main
package path.to.my; import java.io.IOException; import com.googlecode.lanterna.TerminalPosition; import com.googlecode.lanterna.TerminalSize; import com.googlecode.lanterna.graphics.TextGraphics; import com.googlecode.lanterna.screen.Screen; import com.googlecode.lanterna.screen.TerminalScreen; import com.googlecode.lanterna.terminal.DefaultTerminalFactory; import com.googlecode.lanterna.terminal.Terminal; public class Main { public static void main(String[] args) throws IOException { System.out.println("Hello, world?"); Terminal terminal = new DefaultTerminalFactory().createTerminal(); Screen screen = new TerminalScreen(terminal); TextGraphics tGraphics = screen.newTextGraphics(); screen.startScreen(); screen.clear(); tGraphics.drawRectangle( new TerminalPosition(3,3), new TerminalSize(10,10), '*'); screen.refresh(); screen.readInput(); screen.stopScreen(); } }
And my pom.xml
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>hello</groupId> <artifactId>hello</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>com.googlecode.lanterna</groupId> <artifactId>lanterna</artifactId> <version>3.1.1</version> </dependency> </dependencies> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> </properties> </project>
I think your jar isn't included lanterna, you'll need to use a special maven plugin to create a super-jar that includes all dependencies as well.
when i run
java -jar myjar.jar
i getMy MANIFEST.MF
And here is my main
And my pom.xml