0

I tried to use a sourceforge library in my program. On my computer I use Eclipse, and I easily add the jar files to my project. Now, I want to move the code to another computer.

I tried an executable jar file, but the problem is I cannot debug it on the new computer. So, I decided to move the source code and compile it there.

I tried the following but defeated in all of them: (all in Windows Command prompt)

  1. Copy the jar files in the /lib/ext folder of my jre folder and add this folder to classpath
  2. javac -cp ".\lib\*.jar" src/*.java
  3. javac -cp "./lib/*.jar" src/*.java

In all of them the classes that are defined in the library jar files can not be recognized by java! Actually the package doesn't find...

Any idea? Any stupid thing that I am doing?

Ahmad Y. Saleh
  • 3,309
  • 7
  • 32
  • 43
Afshin Moazami
  • 2,092
  • 5
  • 33
  • 55
  • The wild-card character would not work. Instead of ` javac -cp ".\lib*.jar"` did you try really using `-cp fullpath_to_jar;fullpath_to_another_jar"` ? – ring bearer Feb 20 '12 at 20:27
  • I think you should just take your code (the directory where it is), open the project in the new machine and add the jars again the same way you did it in the first machine. Eclipse does not add anything to `lib/ext` and `javac` compiles things to be executed, not to move your code. – madth3 Feb 20 '12 at 20:28
  • Also, this might be useful: http://stackoverflow.com/q/3479466/422353 – madth3 Feb 20 '12 at 20:29
  • unless there is a real need, its a bad idea to add jars to the jre's ext directory. You can add a jar to the class path in the javac/java commands without copying it to the ext directory. – Ahmad Y. Saleh Feb 20 '12 at 20:37
  • On the new machine, I don't want to install eclipse! – Afshin Moazami Feb 21 '12 at 00:02
  • Also, I tried adding the jar files one by one in -cp! it doesn't recognize my classes! – Afshin Moazami Feb 21 '12 at 00:03
  • and maybe it helps! the library that I want to include is HtmlUnit – Afshin Moazami Feb 21 '12 at 00:04

1 Answers1

1

The correct wildcard for matching all jars in a directory is just

-cp "dir/*"

Please see the Understanding class path wildcards section of this page: Setting the classpath

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190