'How to run Java from cmd?
I have a multithreaded program that imports JSON that I want to run through CMD but right now, I can't because it says its not imported.
How can I fix this problem so that I can always run the program on CMD without additional typing at runtime; i.e., just javac program.java and java program.java
The error is:
Client.java:25: error: package com.google.gson does not exist import com.google.gson.Gson;
Client.java:26: error: package com.google.gson.reflect does not exist import com.google.gson.reflect.TypeToken;
Solution 1:[1]
Based on your question & comments, what I am understanding is you are unable to execute your program from command prompt because of external jars.
Please check name of jar where package com.google.gson exists & do following
javac -cp jar_path.jar Program.java
java -cp .:jar_path.jar Program
If you have multiple such jars then use :
javac -cp jar_path.jar;jar1_path.jar Program.java
Edit: since it looks like you don't have manifest file, you can put above command in any .bat file & execute that .bat file:
@echo off
javac -cp jar_path.jar;jar1_path.jar Program.java
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
