I'm on Windows
and I've tried the -classpath
under javac
to no avail. Also tried moving the jar to the src directory, but java file still won't compile. Trying to do a simple import of httpclient in the script.
import org.apache.http.client.*;
You have 3 solutions: add this class in the path of your other compiled classes (respecting the package naming of your directories) add the root directory of this class in your classpath (in your case "C:\java\project\") add this single class into a jar and add this jar to the classpath.
In general, to include all of the JARs in a given directory, you can use the wildcard * (not *. jar ). The wildcard only matches JARs, not class files; to get all classes in a directory, just end the classpath entry at the directory name.
Install your JDK and leave it alone. Do not copy .jar files into your JDK folders!
I'd recommend getting an IDE like Eclipse or Netbeans, if you don't already have one.
I would set up a new project, create or import your source, and set a class path for the project.
If that doesn't work, please tell us:
a) your OS and version
b) your JDK and version
c) your IDE
d) cut/paste the EXACT error message
e) cut/paste the relevant code
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With