This question already has answers here:
How do I run a class in a WAR from the command line?
(11 answers)
Closed 5 years ago.
I am web-development noob and use vaadin 8 for an application and gradle to build the war-file. How can I run the apllication file from command line?
I tried this without success:
java -cp root.war my.namespace.RootServlet
The class is not found.
That will only work if you have an embedded servlet container inside the WAR, that is defined as main class in your manifest file. See the following answer to a similar question:
https://stackoverflow.com/a/3804844/8819761
Related
This question already has answers here:
How do I resolve ClassNotFoundException?
(28 answers)
Closed 22 days ago.
I have created a jar file of a SpringBoot application using gradle.However when I try to run the jar file I am getting the following error:
Here is a SS of the entire project structure along with the build.gradle file content
Cant seem to figure out the problem. Getting this error whenever I run the jar file. I created the jar file using "gradle build" command
you should use full package name com.example.mywebsocketdemo. in build.gradle
This question already has answers here:
JAR vs WAR file specification
(4 answers)
Closed 5 years ago.
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
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.
This question already has answers here:
Is Maven ready for JDK9?
(6 answers)
Closed 5 years ago.
In Java 9, you can create a JAR file with
jar --create --file=mlib/com.greetings.jar --main-class=com.greetings.Main -C mods/com.greetings .
Which has the side effect of adding the MainClass attribute to the module-info.class file in the .jar file.
Do any of the plugins support this yet, or do I need to invoke the Java 9 'jar' command directly?
Is this the right forum to be asking these questions, or is there a better place?
Cheers, Eric
The 'module main class' is actually an attribute of the module-info.class file. It's called ModuleMainClass and set by the Java 9's jar command. The current version (3.0.2) of maven-jar-plugin only writes the file when you specify the manifest.mainClass
This question already has answers here:
Use of the MANIFEST.MF file in Java
(2 answers)
Closed 6 years ago.
I have a basic question about the manifest file: when is this file created?
Is it created in the .class file when we compile a java file? Or should we create the manifest file from the command line after the .class file is created?
Update: you can find the answer here: Use of the MANIFEST.MF file in Java
The manifest file has nothing to do with the compilation/running process of a class.
If you configured your project correctly in your IDE (depending on the IDE), it will be generated during the build project process.
If you are working using the command prompt and notepad, you can always create it manually.
This question already has answers here:
Package not found; javac
(2 answers)
Including jars in classpath on commandline (javac or apt)
(5 answers)
Closed 8 years ago.
I am compiling java files from terminal. But It gives error for external jar files. where can I put external jars. so, it can be used at compile time from terminal?
You can pput it in every directiory and then add it to the classpath:
javac -cp <path_to_jar_including_filename> <class_to_compile>