Issue
At my current company we use the Eclipse IDE to run a Java Web-app. I've learned how to use it pretty well, but the feel and navigation of using VSCode is just suits me better.
If anyone has found a way to start up the server configured as the Eclipse project through command line and is able to use it it with VSCode that'd be awesome!
NOTE: I know there's the bat file for start/stop in the installation, but I can't seem to use those with a configured project. Thanks!
Solution
I am not aware about VSCode, but definitely, I can guide you, how to run Apache Tomcat Server in command prompt, configured for any specific project in Eclipse.
Please follow or check below procedure to do same:
1. Environment Variables and Set Bin Path
Please set new environment variables for JAVA_HOME and CATALINA_HOME
Please add entry in PATH variable for JAVA_HOME/bin
2. Eclipse-Preferences-Server-Runtime Environment
Please add server by selecting same Apache Tomcat Server CATALINA Home Path in preferences of Eclipse (Eclipse-Preferences-Server-Runtime Environment), which you have configured in Step 1. Both configured server must be same for step 1 and step 2.
Please refer below attached screenshot.
3. Eclipse-Java EE Perspective-Servers (View)- Create New Server
If you import your Java EE project then it should be opened in recommended Java EE perspective of Eclipse. Go to Servers View and create new server from configured Apache Tomcat Server
4. Configure or check options of Tomcat Server by double clicking in Server View
Please double click on newly created Apache Tomcat Server link before deploying any Java EE (web) application.
New tab will be opened to configure or set options for Apache Tomcat Server in below sections:
1) General Information
2) Server Locations
3) Server Options
4) Publishing
5) Timeouts
6) Ports
7) MIME Mappings
5. Server Locations
Here, in this section, you will notice three ways to specify server location:
1) Use workspace metadata (by default selected and does not modify tomcat installation)
.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
2) Use tomcat installation (takes control of tomcat installation)
It will display configured path of Apache Tomcat Server.
You should select this option, if you want to run your project from command prompt.
Eclipse will take full control of your configured tomcat installation.
If you want to run your project from command prompt then go to command prompt and start Apache Tomcat server, configured in Step 1 and Step 2.
The startup.bat (for windows) or startup.sh (for linux) files will be in bin folder.
You may set deploy path to the default value as wtpwebapps or browse and select.
3) Use custom location (does not modify tomcat installation)
6. Deploy Project or Add Resource to Server
If you have configured any one of above server locations, as per your requirement then after you should deploy or add project to server.
Thanks and Regards.
Answered By - Manjur