Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Classpath issue with servlet and java class

 
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
 
Rancher
Posts: 43015
76
  • 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...
 
Poop goes in a willow feeder. Wipe with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic