我在文件夹D:\ myProjects \ new_example:
中有java类package new_example;
import com.google.gson.Gson;
class MyClass{
public static void main(String[] args) {
MyClass myClass = new MyClass();
Gson gson = new Gson();
System.out.println(gson.toJson(myClass.getMyDate()));
}
public String getMyDate(){
return "Hello";
}
}
如何在磁盘D的命令行(cmd)中运行此类:? (如果找到gson-2.2.4.jar:D:\ library \ gson-2.2.4.jar和D:\ myProjects \ new_example \ MyClass.java中的MyClass.java),请使用classpath ...如何运行它..?
答案 0 :(得分:1)
答案 1 :(得分:0)
从目录D:\ myProjects:
中尝试此操作java -cp D:\ library \ gson-2.2.4.jar new_example.MyClass
答案 2 :(得分:0)
我建议尝试这个:
java -cp "jar_name.jar;libs/*" com.test.App
jar_name.jar : your jar name with .jar extension
libs/* : relative path to your dependency jars
com.test.App : Class with main(String[]) method