Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add jar files to the Classpath? [closed]

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.*;
like image 570
user1296537 Avatar asked Apr 30 '12 16:04

user1296537


People also ask

How do I resolve a classpath problem?

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.

How do I include all JARs in a folder 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.


1 Answers

  1. Install your JDK and leave it alone. Do not copy .jar files into your JDK folders!

  2. I'd recommend getting an IDE like Eclipse or Netbeans, if you don't already have one.

  3. I would set up a new project, create or import your source, and set a class path for the project.

  4. 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

like image 148
paulsm4 Avatar answered Sep 19 '22 14:09

paulsm4