0

Things worked yesterday , I dont know what I did to break them

I'm trying to compile servlets , connect to MySQL DBs etc . Problem is this.

I have a HW.java file which just prints Hello World , I compile it and run it , it works fine

Now say I need to use Servlet API methods in it So I do this

export CLASSPATH="/Users/User/tomcat.....servlet...api"

now when I try to run (compilation works perfectly ) after exporting CLASSPATH I get this

Could not find or load main class HW

Not only Servlet Programs , even a Hello World program doesnt run Unless I CLear CLASSPATH by using export CLASSPATH=

Things worked fine before dont know what I broke , Please help

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Sainath S.R
  • 3,074
  • 9
  • 41
  • 72

1 Answers1

0

You have to always remember to put class path with your class in the CLASSPATH as well.

export CLASSPATH="/Users/User/tomcat.....servlet...api":$CLASSPATH:/somedir/where/your/HW_class_is

And remember to put top dir where your package is declared. Let's say you have class

mypackage.mysubpackage.HW.class

inside dir

$HOME/test/mypackage/mysubpackage

you have to add:

$HOME/test/ to CLASSPATH
Oo.oO
  • 12,464
  • 3
  • 23
  • 45