0

I'm totally newbie in Java programming, but somehow I need to run Java project to see what exactly its doing, but i don't know how to find mainClass, which I need to do mvn exec:java (I already did mvn install and compilation/installation went without errors)

kserrri
  • 19
  • 1
  • 1
    It's going to be pretty hard to help you without knowing which project you're working with. Check your `target` directory, there should be some `.jar` files in there. You can try executing those to see if they have a main class specified (or check their `META-INF/MANIFEST.MF` files to see if they have a main-class specified). You could also try to `grep` over the source files for a `public static void main`. – Jeffrey Jul 05 '15 at 17:49
  • thank you for your help, I found App.java file with 'public static void main' , but still don't know how to use this knowledge. any ideas? – kserrri Jul 05 '15 at 19:16
  • Compile App.java and run it? – Jeffrey Jul 05 '15 at 19:23
  • I doesn't work (multiple erros) If it would be so simple, then there would be no point in using maven. I think, that I should look for some jar file in .m2/repository rather than in source code, hence 'mvn install' compiled this program already (?), or just use some mvn command. Am I wrong? – kserrri Jul 05 '15 at 21:13
  • `mvn compile` will compile the code for you in `target/classes/`. `mvn package` will compile the code for you and create a `.jar` file in `target/`. Use either of those two options and execute the class. All `mvn install` does it take the `.jar` from `mvn package` and put it in `.m2/repository/`. – Jeffrey Jul 05 '15 at 21:35
  • I did mvn package and get App.class, but im unable to run it - i tried just java App (cou not find or load main class App - java Hello World program is working properly) and also mvn exec:java -Dexec.mainClass="com.x.y.App (an exception occured while execting the Java class . com.x.y.z.App ) - am I doing sth wrong or its not my fault? – kserrri Jul 05 '15 at 23:37
  • It's really hard to know what's going on unless you tell me what project you're trying to run. What was the exception you got from `mvn exec:java`? What happens if you try `mvn exec:exec`? – Jeffrey Jul 06 '15 at 01:21
  • you should probably read about maven or go through http://stackoverflow.com/questions/1089285/maven-run-project – Vinay Prajapati Sep 18 '15 at 03:08

0 Answers0