开发者

Running Java from command. Java errors with -cp and without (JDBC error / Class not found)

I am trying to compile and run a program from the command line. When we compile it, we do -cp and link it to our jdbc jar.

javac -cp jdbc.jar *.java

If we then just do: java debugger

We then get an error saying that the driver can't be found.

However, if we do:

java -cp jdbc.jar debugger

Then we get an error saying that the class Debugger can't be found.

开发者_C百科

Which way do we need to do it? Since neither is working, any suggestions on what we might need to check to fix the correct method?

Many thanks from a tired group of students!


You also need to tell the java command where the javac command left the .class files. Perhaps

java -cp .:jdbc.jar Debugger

would do the job in your case?


I believe it should be -classpath not -cp. Please check the javac documentation and also here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜