• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java invocation error

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the current directory I have a folder called xyz and inside xyz I have a class file called C.class

I am trying to execute with the below command and I get an error -



If I execute with - I get the correct result with out an error.

Please clarify me what is the error in my previous invocation.

-Jerry.
 
Ranch Hand
Posts: 558
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jerry,
java or javac searches for given class in the fallowing manner

1) first it will search in java lib files
2) it will search in OS environment variables ex: CLASSPATH
3) next if you specify any classpath then it will search there.
Remember this override the Os env paths.

In your case
step 1) you are overriding Os classpath by having your own in java cmd.
But there is no "." after path.
thats why it will say i don't know xyz dir.

step 2) when you compile with java xyz/C, you are able to complie. This means your Os classpath has "." some where.

Hope you clarified.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try using -classpath instead of -cp. In some machines the abbreviation won't work.

/thuwa
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic