I am trying to use the JSON simple library, but I just can'e execute my program with it.
I am trying to compile this way:
$ javac -classpath json.jar TestClass.java
(json.rar is the json-simple file)
And it compiles ok. But I'm having trouble running it. This is how I am trying to run the program:
$ java -classpath json.jar:. TestClass
And I get the following error: Error: Could not find or load main class TestClass
But the file IS there. After an ls, this show up:
DBImporter.class json-simple-1.1.1.jar TestClass.class testfile2.txt
DBImporter.java output.txt TestClass.java
json.jar resource.db testfile.txt
I'm searching on the internet for hours, and no solution works for me. I don't know if this is relevant, but this is my TestClass
import java.io.*;
import org.json.simple.*;
public class TestClass{
public static void main(String[] args){
JSONObject obj = new JSONObject();
}
}
Thanks in advance!
I managed to run the program using the following command:
$ java -cp json.jar:./ TestClass
Putting a slash after the dot. I'm not sure why it worked, if anyone know the explanation it would be nice, mainly because I haven't seen this solution anywhere when searching for it.