0

I need to make an executable jar for my ending project and I keep getting the "Could not find main class"....

I've tried with export > runnable jar and export > jar file (and I did chose the main) in both cases I get the same error.

Details in the runnable:

My run configurations for the main of the project:

The dependencies in my project:

I'm totally lost and i don't know where's the problem

Oliva
  • 13
  • 2

1 Answers1

0

Verify that you can start your application like that:

java -cp myjarfile.jar Principal.java

You're double-clicking the file on a windows explorer window? Try to run it from a console/terminal with the command

java -jar myjarfile.jar

Please check below link for further clarification . Running JAR file on Windows

Umeshwaran
  • 627
  • 6
  • 12
  • To run an application in a non-executable JAR file, we have to use -cp option instead of -jar. We'll use the -cp option (short for classpath) to specify the JAR file that contains the class file we want to execute: ```java -cp jar-file-name main-class-name [args …]``` – Umeshwaran Jun 02 '21 at 20:45
  • Eg: java -cp JarExample2.jar com.sample.demo.Start – Umeshwaran Jun 02 '21 at 20:46
  • You can start your jar by double clicking by tweaking some configurations . See https://stackoverflow.com/questions/8511063/how-to-run-jar-file-by-double-click-on-windows-7-64-bit . Hope it helps – Umeshwaran Jun 02 '21 at 20:46
  • 1
    I just had to delete other jdks, many thanks you were my saviour – Oliva Jun 02 '21 at 22:13
  • Please upvote my answer if it helped.Thanks :) – Umeshwaran Jun 02 '21 at 22:27