错误:在编译Java代码时包不存在。

huangapple go评论75阅读模式
英文:

error:package doesn't exist while compiling java code

问题

以下是翻译好的内容:

我正在尝试编译我的Java文件,但出现了错误:
错误:包不存在

项目目录结构:

project/src/test/java/com/mypack/Test.java

我的测试文件包括:

import org.apache.ibatis.jdbc.ScriptRunner;
import org.h2.tools.Server;

我正在执行:
在位置src/test/java/com/mypack执行 javac Test.java,但它没有解析依赖关系,并且显示包不存在的错误。

错误:找不到包org.apache.ibatis.jdbc
import org.apache.ibatis.jdbc.ScriptRunner;
错误:找不到包org.h2.tools
import org.h2.tools.Server;
英文:

I am trying to compile my java file but it is giving error:
error:package doesn't exist

Project Directory structure:

project/src/test/java/com/mypack/Test.java

My test file include:

import org.apache.ibatis.jdbc.ScriptRunner;
import org.h2.tools.Server;

I am doing:
javac Test.java at location src/test/java/com/mypack but it is not resolving the dependencies and giving package doesn't exist error.

error: package org.apache.ibatis.jdbc does not exist
import org.apache.ibatis.jdbc.ScriptRunner;
error: package org.h2.tools does not exist
import org.h2.tools.Server;

答案1

得分: 1

我不知道你使用的构建系统是什么,但我猜你是手动使用javac进行编译。请确保包括其他库。请查看这个链接,这可能会对你有所帮助。
https://stackoverflow.com/questions/5112607/how-to-include-libraries-in-java-without-using-an-ide

英文:

I don't what build system you are using but realizing that you are using javac i guess you are manually compiling it. Please make sure including other libraries as well. Please see the link this might help you
https://stackoverflow.com/questions/5112607/how-to-include-libraries-in-java-without-using-an-ide

huangapple
  • 本文由 发表于 2020年8月20日 01:20:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63491997.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定