So many mistakes, it is hard to know where to start :-)
You can put the Maven project / source tree anywhere you like.
You can put the JAR file created by Maven anywhere you like.
You need to put the JAR file on the classpath, and the best way to do that is to use the -cp
option.
You need to specify the entry point by giving the fully qualified name of the class ... not a filename. The ".class" suffix is a mistake.
Assuming that the java
command is on your PATH, the command array should look something like this:
String[] command = {"java",
"-cp", "/some/path/to/MyProject.jar",
"com.acme.MainExternal",
"test"};
UPDATE
Given that the class you are trying to run and its dependencies are in the WAR file, you are better off leaving it as-is, and using a classpath like:
"/.../ClassOmicsTracer/WEB-INF/classes:/.../ClassOmicsTracer/WEB-INF/lib/*"
where "/.../ClassOmicsTracer" is the absolute file path to your webapp. If you are on Window, change the :
to a ;
.