• Post Reply Bookmark Topic Watch Topic
  • New Topic

Classpath issue with servlet and java class

 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I have a servlet and a java class under the same package. I call the java class from the servlet i.e:

And I get this error message:


I don't understand if both the class files are in the same location, how can it not find the second class??? Moreover if I go to that same location using command line and give the same command there,it works fine...

Can someone please tell me how to resolve this classpath issue???

Thanks
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Executing a process this way is not the same as starting it from the command line. In particular, the class which starts it has no bearing on directories, classpaths used etc. Add an explicit classpath to your command, and it should work fine.

But since you're running a Java program, wouldn't it be much more elegant to instantiate an object of type 'JavaClass', and then call its methods directly?
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf,
That resolved the issue...I want to fork out the process and run it under a separate JVM,thats why i did that...

Thanks Again...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!