Create a Maven Project in Eclipse and run .jar file

Create a Maven Project in Eclipse and run .jar file

  • Go to the File option => In the drop-down menu, select New => select Maven Project

  • Select desired path => click next

  • Select latest org.apache.maven.archetypes from catalogs Group id and maven-archetype-quickstart from Artifact id => click next

  • Enter the Group ID?with any name like com.proj and Artifact ID as demoMavenProj => click finish

  • Eclipse console might ask for confirmation like below => type Y => hit enter then project will be created, you will see BUILD SUCCESS in console.

  • Project has been created, now open pom.xml, You will see all the basic information, such as the Artifact ID, Group ID, etc. You will also see the junit dependencies for test cases.

  • you will see AppTest.java a default test case written in JUnit.

  • you will also see default class as App.java which was create as part of initial boilerplate.

  • To create a .jar file, select Maven build => type any goal name like package => click run

  • You might error in console like Source option 7 is no longer supported. Use 8 or later. OR Target option 7 is no longer supported. Use 8 or later. and BUILD FAILURE, update version number in pom.xml and retry

  • Do project refresh and you will see demoMavenProj-0.0.1-SNAPSHOT.jar file in target folder

  • Go to folder and hit cmd, and execute .jar file using java -jar demoMavenProj-0.0.1-SNAPSHOT.jar

  • You might see error like below and open archive like below => META-INF => open MANIFEST.MF => add Main-Class: com.proj.demoMavenProj.App

  • now, run command java -jar demoMavenProj-0.0.1-SNAPSHOT.jar in cmd.

Now a days I am learning Java so credit also goes to Navin Reddy Hyder Abbas All the concepts have been explained in a clear and engaging manner, I appreciate your teaching style.

Course Link: https://courses.telusko.com/learn/Live-Java-Course

My git repo for java learning https://github.com/anu3dev/learningJava



要查看或添加评论,请登录

Anurag K.的更多文章

社区洞察

其他会员也浏览了