views:

997

answers:

4

Ok, this is working on windows. My Java app is running and functioning normally

javac -classpath .;ojdbc14.jar -g foo.java
java  -classpath .;ojdbc14.jar  foo

However, when I do the same thing on Unix I get this error: ojdbc14.jar: not found

What am I doing wrong? I know the ";" is telling my shell that ojdbc14.jar is a new command, but I'm not sure how to fix this.

+12  A: 

Use a colon (":") instead of a semicolon (";").

See Setting the class path (Solaris and Linux) vs Setting the class path (Windows)

James Schek
A: 
javac -classpath '.;ojdbc14.jar' -g foo.java
java  -classpath '.;ojdbc14.jar'  foo
InsDel
OK, you're correct that the single quote will prevent the shell from interpreting the ";" as a command separator, but a Unix java isn't going to understand ";" in the classpath.
Ken Gentle
-1 for semicolon on linux
orip
*If* java will recognize the semicolon in a classpath on non-Windows platforms, it is neither guaranteed nor documented.
James Schek
+1. The -1 was unwarranted. InsDel's solution does work, and is not inherently unhelpful. It might not be the optimal solution, but it is a solution.
CodeSlave
Yeah, but I think James's point is valid - it may not always work.
Matthew Schinckel
+2  A: 

The final solution was:

javac -classpath .:ojdbc14.jar -g foo.java
java  -classpath .:ojdbc14.jar  foo

Note: Using '.;ojdbc14.jar' removed the initial error message I was getting, but resulted in the following errro:

Exception in thread "main" java.lang.NoClassDefFoundError: foo
CodeSlave
How did you fix that error?
Daryl Spitzer
I changed the semi-colon to colon as in the accepted answer.
CodeSlave
A: 

Use ant, or even better use ant with a continuous build environment like Hudson and a SCM like SVN.

garym