• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I use a path as an argument without breaking the -classpath option?

 
Todd Patrick
Ranch Hand
Posts: 31
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Specs.]
SUN Solaris
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Server VM (build 1.5.0_06-b05, mixed mode)

[Question.]
How do I use a path as an argument without breaking the -classpath option?

I have the following Korn Shell Script:



When I run the shell script, I return the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: /EAIStorageNumbers/v1/0001/weekly05222006/csv

Thus, the -classpath option sees the first argument as a classpath.

When I remove the -classpath option, I get a different error, which is another issue:

Exception in thread "main" java.lang.NoClassDefFoundError: au/com/bytecode/opencsv/CSVReader
at com.dtn.refinedfuels.EAIStorageNumbers.main(Unknown Source)


Thoughts or suggestions on how I can get the -classpath option to work with the defined Korn Shell Script variables would be greatly appreciated.

Thanks,
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Carl explained in your previous post, the -classpath argument is supposed to be followed by a list of directories or archives where the JVM can find the classes it needs. There's no shortage of guides to how the classpath works, including our faq and the JVM Release Notes.
 
Todd Patrick
Ranch Hand
Posts: 31
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe: I understand that. I've read the faq.

"com.dtn.refinedfuels.EAIStorageNumbers" is the class file in the package "com.dtn.refinedfuels"

That why I did a cd to the directory "/EAIStorageNumbers/v1/bin/" which holds the package prior to executing the class.

I just don't understand why an argument would be looked at as a -classpath option when I've followed the rules:

java [-options] class [args...]

From my Korn shell script, how would you set up the execute class line?

Thanks,
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
-classpath interprets the next thing on the command line as its argument; in your case, it's the class name. Then the next thing after that is interpreted as the class name; this is the first argument to your program.

The point is that you cannot say "java -classpath ClassName". You must say "java -classpath PATH ClassName". I don't even understand what you're trying to do by using -classpath without its PATH argument -- can you explain?
 
Todd Patrick
Ranch Hand
Posts: 31
Android Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My sincere apologies, yes - I was missing the PATH value for the -classpath option.

My execute class line is now:



"Thank you for setting me straight!"
[ May 23, 2006: Message edited by: Todd Patrick ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic