I have 2 classes
CLASS1 (the main class)
- calls threading glass
CLASS2 (the threading class)
- calls function
- calls json.simple.jar functons
and a .JAR (https://code.google.com/p/json-simple/)
jar/json.simple.jar
Now the main problem is that i actualy managed to make both classes to compile with those commands
javac -d . -cp '.:jar/json.simple.jar' *.java;
this will create a folder named package1 and then when i try to run it it gives me the error
java javanolo.CLASS1 -jar 'jar/json.simple.jar';
Selected (9) IPS ... <-- this is the first **println**
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
at javanolo.CLASS1.main(CLASS1.java:70)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
and i assume this is because it is not finding some of the json simple functions. Why that? I've imported them
// json encode/decode
import org.json.simple.JSONValue;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
and i am sure that i have imported the .jar, because if i run
javac -d . *.java;
error :
import org.json.simple.JSONValue;
^
CLASS1.java:14: error: package org.json.simple does not exist
import org.json.simple.JSONObject;
^
CLASS1.java:15: error: package org.json.simple.parser does not exist
import org.json.simple.parser.ParseException;
^
CLASS2.java:16: error: package org.json.simple does not exist
import org.json.simple.JSONValue;
^
CLASS2.java:17: error: package org.json.simple does not exist
import org.json.simple.JSONObject;
^
CLASS2.java:18: error: package org.json.simple.parser does not exist
import org.json.simple.parser.ParseException;
^
CLASS2.java:148: error: cannot find symbol
public Map<String,String> openAndGetGeoDataByProxy(String ip,String port,int timeout) throws IOException, InterruptedException, ParseException
^
symbol: class ParseException
location: class CLASS2
CLASS2.java:99: error: cannot find symbol
} catch (ParseException ex) {
^
symbol: class ParseException
location: class CLASS2
CLASS2.java:188: error: cannot find symbol
Object jsonObject = JSONValue.parse(line);
^
symbol: variable JSONValue
location: class CLASS2
CLASS2.java:191: error: cannot find symbol
JSONObject jsonArray = (JSONObject)jsonObject;
^
symbol: class JSONObject
location: class CLASS2
CLASS2.java:191: error: cannot find symbol
JSONObject jsonArray = (JSONObject)jsonObject;
^
symbol: class JSONObject
location: class CLASS2
CLASS2.java:194: error: cannot find symbol
JSONObject jsonArray2 = (JSONObject)jsonArray.get("array_result");
^
symbol: class JSONObject
location: class CLASS2
CLASS2.java:194: error: cannot find symbol
JSONObject jsonArray2 = (JSONObject)jsonArray.get("array_result");
^
symbol: class JSONObject
location: class CLASS2
so i know for sure that json-simple.jar is being used when compilation.
- The main question is, how can i run CLASS1 and CLASS2 with that .jar file?
- Why LINUX based system is so different then the WINDOWS NETBEANS? I mean java is platform independent ...
- Ho can i connect NETBEANS to my server trough SFTP so i can code there directly.
Thanks.
EDIT TRIES
i have tried the following commands, none of them works, it gives me the message like i was running the java -help
command
try1
java -cp .;jar/json.simple.jar javanolo.CLASS1
try2
java -cp .;'/root/folder/folder/jar/json.simple.jar' javanolo.CLASS1
try3
java -cp .;/root/folder/folder/jar/json.simple.jar javanolo.CLASS1
can anyone help me please (would be better on chat)? i really need this