I know that questions have been asked before, but it does not solve my problem in my school project.
I downloaded the JSON.simple
jar file from https://mkyong.com/java/json-simple-example-read-and-write-json/, then move it to the src
directory and import it.
In the src folder I also have Main.java
, Manager.java
and Peer.java
, in which Manager
and Peer
uses the json.simple
package.
I am using Intellj.
At src
directory, I try to run javac Main.java
, I get 14 errors including
import org.json.simple.parser.JSONParser;
^
.\Manager.java:95: error: cannot find symbol
Then I tried to provide the full path for the jar file: javac -cp C:\Users\yiges\Desktop\COMP90015\Project3\WhiteBoard\src\json-simple-1.1 Main.java
I get the 4 errors including:
imple-1.1 Main.java
Main.java:15: error: cannot find symbol
Manager manager = new Manager(port);
^
symbol: class Manager
location: class Main
Then I tried to compile all java files: javac -cp C:\Users\yiges\Desktop\COMP90015\Project3\WhiteBoard\src\json-s imple-1.1 *.java
or simply javac *.java
I get again 14 errors including:
Manager.java:1: error: package org.json.simple does not exist
import org.json.simple.JSONObject;
^
How do I solve this issue?
Thanks for helping!
Problem solved.
It turns out that I should use the
javac -cp .;json-simple-1.1.1.jar C:\Users\yiges\Desktop\COMP90015\Project3\WhiteBoard\src\Main.java
command to compile the code