0

I want to put my java Project in a .jar or in an .exe. I can not find a solution for my problem. That is my project structure:

  1. project

    1.1. pom.xml
    1.2. .idea
        1.2.1. libaries
            1.2.1.1. many maven dependency files
    1.3. .GUI
        1.3.1. .idea
            1.3.1.1. libaries
                1.3.1.1.1. many maven dependency file
        1.3.2. src
            1.3.2.1. main
                1.3.2.1.1. java
                    1.3.2.1.1.1. .java files
                1.3.2.1.2. recources
                    1.3.2.1.2.1. .fxml files
                    1.3.2.1.2.2. CSSStylesheets
                        1.3.2.1.2.2. .css files
    

I follow instructions on youtube for creating a .jar in Intellij (https://www.youtube.com/watch?v=ZlyTn8PZ3Fc) but the .jar was not executable. It just print this Display parameters as parsed by Maven (in canonical form) and comparison result: to the console after running java -jar file.jar. (After the double dot there does not come more information.)

Next I found another youtube video that shows me it does not work like in the first video because of the maven dependencies (https://www.youtube.com/watch?v=HGHu-SzL-5E). In this video I do not know what to do in 5:39. He copies something but I do not know from where that is. I tried to put the same files in there like he did but it does not work. There comes a ClassNotFoundError that it can not be found the .fxml files. Then I do not write them in the command but all other .java files but it was the same error.

On this (https://introcs.cs.princeton.edu/java/85application/jar/jar.html) site I had my next try. I follow the instructions like this: I dreated a .mf file and put all .fxml and .java and .class files in the command but it can not be found the .class files so I put them out of the command. And then ist comes a ClassNotFoundError. It can not find the Main class. Intellij mark it in the .mf file red as well and I do not know why.

Then I follow the instructions of this (https://cwiki.apache.org/confluence/display/MAVEN/Tutorial%3A+Build+a+JAR+file+with+Maven+in+5+minutes) site but there an empty .jar file was created.

Now I do not know what I did wrong or what I miss so I hope someone can help me.

Elke
  • 1
  • 1
  • Your problem could be because this is not the standard Maven project structure. You would normally have /src in the root where the POM is. You have it nested in .GUI. Not sure how you came about that project structure but I would create the Maven project on the command line first then import into your IDE. – Dan Saunders Jun 27 '20 at 09:40
  • So you mean that I should put the src directory in the project directory? Or is it possible to put the pom in the GUI? – Elke Jun 27 '20 at 10:15
  • So tried both and follow the instructions from (https://cwiki.apache.org/confluence/display/MAVEN/Tutorial%3A+Build+a+JAR+file+with+Maven+in+5+minutes and from https://introcs.cs.princeton.edu/java/85application/jar/jar.html but it is the same Error as above. – Elke Jun 27 '20 at 10:28
  • Does this answer your question? [How can I create an executable JAR with dependencies using Maven?](https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven) – D.B. Jun 27 '20 at 22:34

0 Answers0