I have web application inside it I have a timer in a main method I wont to lunch the timer from a command line when I did this command : java -classpath mywar.war my.packege.myclass I got main class not found
Asked
Active
Viewed 959 times
-2
-
Below question is an exact match of your's, you can check the answers suggested there: https://stackoverflow.com/questions/1842972/how-do-i-run-a-class-in-a-war-from-the-command-line I'm not sure of your exact requirement but you can also expose your timer code via a Rest call and use curl, browser or any other rest client to run it. – Rahul Jan 18 '18 at 13:20
1 Answers
-1
That won't work. The class files are in a different place in a WAR file compared to a JAR file. You can't use the two interchangeably. You'll need to repackage your code as a JAR file.
Better still, package your code as a JAR in a separate 'project' and then place the JAR in WEB-INF/lib in the WAR file. i.e. treat the JAR file as a dependency.

Mark Thomas
- 16,339
- 1
- 39
- 60