user2702279
user2702279

Reputation: 31

Could not create the Java virtual machine error?

I am using Apache tomcat. I am running Tomcat through cmd.exe. I have been able to deploy a "Hello World" webapp with no problems. However, I have tried to run the servlet 'HelloServlet.java' by typing: "C:\apache-tomcat-8.0.0-RC3\webapps\hello\WEB-INF\java -d classes src\mypkg\HelloServlet.java" Or "C:\apache-tomcat-8.0.0-RC3\webapps\hello\WEB-INF\classes java HelloServlet.java"

but I always get the error "Unrecognized option: -d Error: Could not create the Java Virtual Machine Error: A fatal exception has occurred. Program will exit"

If I try: "C:\apache-tomcat-8.0.0-RC3\webapps\hello\WEB-INF\javac -d classes src\mypkg\HelloServlet.java"

then I get the message " 'javac' is not recognized as an internal or external command, operable program or batch file "

Upvotes: 0

Views: 3289

Answers (1)

Juned Ahsan
Juned Ahsan

Reputation: 68715

There are multiple problems in your approach:

  1. First you need to learn about Servlets. Servlets do not run as a standalone program
  2. Tomcat is a container for web application deployment. Web applications need to be organized in a proper format. Web apps can contain servlets.
  3. Tomcat is not used for compiling servlets/java programs
  4. Follow a simple tutorial to learn about servlets and tomcat

Upvotes: 4

Related Questions