A
A
AlexandrMa2022-02-08 11:32:46
Java
AlexandrMa, 2022-02-08 11:32:46

How to properly import third-party classes?

The Example.java file is located in the C://JAVA/Example.java folder. I
compile it from the command line like this: javac Example.java
Everything is fine. But now I have to work with Json (or any other plug-in class), dancing begins.

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONString;

Does not work.

I downloaded a bunch of different files and archives, including JsonObject.class and JsonArray.class and many others. I added them here C://JAVA/, but the import still does not work.

I have Idea installed. There it's all done through the project structure.
But on other computers where there is no editor, the program must be run from the command line. That is, I still need to figure out where to put the files and how to connect them using only the compiler from the command line. This is real? If so, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2022-02-08
@AlexandrMa

Discover build systems like Maven and Gradle (I recommend the latter). They will take care of all the dependencies and put them in the classpath correctly. Working on any more or less complex Java project without such systems is one big ongoing pain.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question