Right click on the project in which you want to put jar file. A window will open like this

Click on the AddExternal Jars there you can give the path to that jar file
Answer from Ram kiran Pachigolla on Stack OverflowRight click on the project in which you want to put jar file. A window will open like this

Click on the AddExternal Jars there you can give the path to that jar file
As of rev 17 of the Android Developer Tools, the correct way to add a library jar when.using the tools and Eclipse is to create a directory called libs on the same level as your src and assets directories and then drop the jar in there. Nothing else.required, the tools take care of all the rest for you automatically.
Videos
- Right click on the Eclipse project,
- choose Properties
- Select Java Build Path
- Click the libraries tab
- click add external jars
- find the json jar(s) and add them.
This is a wrong download I believe. You need JSON-Simple library from here http://code.google.com/p/json-simple/ . Your link points to another implementation.
After download the *.jar should be added to the classpath. How you do it depends on the tools you use. In Eclipse it is right-click on the project, Properties->Libraries and add the new JAR.
Hi,
I'm adding JSON.simple to my java in Processing, but I'm not sure how to add this to my classpath. I think/imagine that Processing uses its own Java, wrapped up somehow in the software. Hopefully this is relatively straightforward...
Thank you
You need to use the fully-qualified class name, which includes the package:
import org.json.JSONArray;
(And yes, that is the correct way to add classes/jars to your project's classpath in Eclipse.)
If you wana to use servlets in tomcat you also have to copy the org.json.jar to lib in tomcat folder. If not eclipse will not give you any error but tomcat will.
Update for latest version
Pre-requisite: In VS Code you need to open the folder and not just file to include any jar file for compilation, running, debugging and testing
VSCode works fine with maven or gradle, and if we are using any of those, we should use maven or gradle for dependency management.
If you are not using any dependency management, then there are two options to add jar file
Option 1: Manually
Open .vscode/settings.json file (if not present, you can create one) and add required jar file there as shown below. In this case all the jar files present in lib directory will be included + I have added common-logging-1.1.1.jar which is located outside the project directory
{
"java.project.referencedLibraries": [
"lib/**/*.jar",
"c:\\path\\to\\jarfile\\commons-logging-1.1.1.jar"
]
}
Option 2: Via User Interface
If Java Extension is enabled then on left panel there will be Java Dependencies.
Inside there you can click on + symbol to add customer jar files. With this method too, the settings.json file will be updated

Old Answer kept for reference...
VSCode works fine with maven or gradle. But without those, as far as I know they have not provided any direct way to add jar file in classpath.
The workaround is to add the entry in .classpath file manually.
For e.g. in below file I have added common-logging-1.2.jar located in lib directory manually by adding a line <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.2.jar"/>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.2.jar"/>
</classpath>
Update
Finally VSCode team is working towards a better solution. This is still work in progress, but you can refer to this link for better aproach https://github.com/microsoft/vscode-java-pack/issues/94#issuecomment-573487982
Update April 2020
VSCode Extension update now supports this feature out of the box. Now VS Code Java lets you work with JAR files directly without any build tools. Go to JAVA DEPENDENCIES view, find the Referenced Libraries node and click the + icon.
Reference https://github.com/microsoft/vscode-java-pack/blob/master/release-notes/v0.9.0.md#work-with-jar-files-directly
Follow these steps in vscode(2022)
Make sure Extension Pack for Java is installed
Install Extension Pack for Java, you may need to restart the vscode.
Project Structure
Create the following
.vscode/
| -- settings.json
bin/
lib/ <-- Add here all the .jar files
src/ <-- Add here you java source code
So that the project structure should look like this

Add settings to settings.json
{
"java.project.sourcePaths": [
"src"
],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar",
]
}
{ "java.project.sourcePaths": [ "src" ], "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/**/*.jar", ] }
java.project.sourcePaths: Path of your java source code
java.project.outputPath Binary output
java.project.referencedLibraries: The
.jarfiles
Now, restart vscode and also if you still have error you many need to Clear file content cache in Visual Studio Code
Also you should see now the library in the Referenced Libraries list. (Note: this may be updated in future vscode version, like name, position and so on)

You have to use the -classpath when running with java as well.
java -classpath json.jar MyClassName
You're making two mistakes:
- The message you get from the compiler is a note, and not a compilation error. Follow the instructions to get details
You forget to set the classpath when running the app:
java -classpath json.jar;. MyClassName
(assuming you're on windows, and you're in the directory containing MyClassName.class). If you're on Unix, replace the ; by a :.
Note that it's bad practice to put classes in the default, root package.
If using Maven, add this dependency to your pom.xml
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
For Gradle, add this to your build.gradle
compile 'javax.json:javax.json-api:1.0'
Going to assume that you are not using Java 7 and thus need to add the JAR file directly to your project path:
Here's the link to the JAR
And where it came from: http://jsonp.java.net/
Download and add to your project build path.