java - java类和 “import com.google.gson.*”错误

标签 java compiler-errors

在我的Java servlet项目中,我使用了ajax,在那里使用了gson jar文件。在kali linux中没有IDE Eclipse作为操作系统。
我已经将gson.jar放在WEB/lib/*中,并用javac -d ... -cp so the classpath is correct and when i use the same program in Eclipse it works well (here i entered the servlet-api.jar and WEB/lib/* to include all files)编译了程序,但是我遇到了这个错误

src/com/Servlets/AjaxController.java:9: error: package com.google.gson does not exist
import com.google.gson.*;
^
请引导我解决这个问题,首先谢谢

最佳答案

首先,请确保您使用的Java版本> = 1.6,因为从该版本开始,正在考虑使用通配符(*)。
其次,您的类路径中的路径必须由:分隔,而不是; (在Windows中)
第三,确保在每个路径字符串的末尾都使用了通配符。

关于java - java类和 “import com.google.gson.*”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64699533/

相关文章:

java - 想要计算 cmd 参数数组中的字符数

java mysql输入NULL

Java 无法及时收集垃圾

compiler-errors - CGAL 编译器错误 : undefined reference to `CGAL::assertion_fail(char const*, char const*, int, char const*)'

c# - 三元条件下的隐式转换问题

c++ - 在C++代码的编译器中出现错误,详细内容在

java - 使用 PowerMock 测试 Thread.sleep 不起作用

java - 使用拦截器计算 Mule 流的处理时间

python - 考虑到 p 在 python 中是素数,当我执行 p/p+1 + p+1/p 操作时出错

c++ - 如何在Windows上使用MinGW编译C++?