Compiling and Running java in Unix ( coming from Windows )

試著忘記壹切 提交于 2019-12-10 16:19:41

问题


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.


回答1:


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

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




回答2:


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



回答3:


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



回答4:


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



来源:https://stackoverflow.com/questions/322098/compiling-and-running-java-in-unix-coming-from-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!