I have a Maven Web Application that contains only a single class in the Source Packages folder. I have obtained the war file from this project which I would like to copy and run on another machine. I would like to be able to run only that specific class using the commandline.
The reason why I still want to use the war file is because that class implements a RESTful service so I don't know if there is another way to go (like making it a jar and end right there). My war file also contains several dependencies and one of them has the provided scope:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
This is an extract from the pom.xml file and is the only dependency that does not appear in the WEB-INF/lib
folder. However, I don't know if this is the problem.
My class is named ClientSide
and is under the client
package. Running the command:
java -cp warFileName.war client.ClientSide
resulted in this error:
Error: Could not find or load main class client.ClientSide
Adding Main-Class: client.ClientSide
to the manifest file did not change anything. I have tried the solutions proposed here: How do I run a class in a WAR from the command line? but with no luck. This error would keep repeating.
The only way I can run that class is by right-clicking on the class inside the Web Application and select Run File
from netbeans, which is very annoying.