Error: Could not find or load sample main class.

I tried to fix this problem for about 4 hours. Nothing succeeded. I use Java and Intellij and JavaFX.

What do I want to do? I created a JavaFX program on Windows. I want to execute this .jar on my Raspberry Pi.

Whenever I want to run this jar, I get this error in the console:

Error: Could not find or load sample main class. Main

sample is the package, and Main is my class with the main method.

The program runs JUST FINE under the windows. (Inside and Out IntelliJ).

What steps have I already taken?

  • Java is relevant on my pi. java -version returns 1.8. So here we are well.

  • I imported my used libraries (Pi4J) into my project as part of the project-structure library →. and within modules → dependencies.

  • I have identified a new artifact. I set the main class (sample.Main), and in JavaFX I set the application class to sample.Main (both provided to me by Intellij). Then I create the project by going to assembly → assembly of artifacts.

    / li>
  • I checked MANI-FEST under / src / META -INF / MANI-FEST and it really is Main-Class: sample.Main

  • On my pi, I went in the direction the jar file is located. Then I ran: sudo java -jar Keimgeraet.jar, which should work fine. But then I get an error.

  • I probably did more, but already forgot ...

Which might work, but I don't know how I would like:

In other threads, people noted that my specified paths may be wrong on another computer (in this case pi)

[imgur], . , .

! java pi, .

Sidequestion: jar?

, !

+4
1

JAR Maven?

( archive.manifest.mainclass maven) ( JAR: , "xxx-jar- -dependencies.jar" ).

Maven, .

+1

Source: https://habr.com/ru/post/1659470/


All Articles