I am working in Java Maven project. There is a .bat
file in the root of the project which invokes a Java class with some arguments something like this:
java my.package.MyClass abc hi 1
Now, my project jar is built in the target directory of that project when I do mvn clean install
. When I run that .bat
file it gives me the below error
Error: Could not find or load main class my.package.MyClass
Project's pom.xml
only contains jars as dependency.
Do I need to do something in pom.xml
to make it work?
please provide your pom.xml
so we can look for it, anyway,
do you use maven-jar-plugin
?
something like this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>your.main.class.package.ClassName</mainClass> // your main class
</manifest>
</archive>
</configuration>
</plugin>
and try to run your *.jar
with command java -jar yourjar.jar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.