创建包并将其导入另一个java文件

创建包并将其导入另一个java文件,java,import,packages,jmh,Java,Import,Packages,Jmh,我有一个结构为src/org/openjdk/jmh的文件夹,其中有各种文件,如注释、生成器、infra、profile、results、runner、util 所有这些文件中都有各种java程序 现在在src/com/user目录中,我有一个基准代码“JMHSortBenchmark.java”,它使用 import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.*; 但是当我编译JMHSortBenchmark.

我有一个结构为src/org/openjdk/jmh的文件夹,其中有各种文件,如注释、生成器、infra、profile、results、runner、util

所有这些文件中都有各种java程序

现在在src/com/user目录中,我有一个基准代码“JMHSortBenchmark.java”,它使用

import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.*; 
但是当我编译JMHSortBenchmark.java时,我得到一个错误

package org.openjdk.jmh.annotations does not exist
package org.openjdk.jmh.runner      does not exist
如何消除这个错误,或者如何创建包并将它们导入到基准代码中


或者换句话说,我如何创建一个包org.openjdk.jmh.annotations和org.openjdk.jmh.runner,从而导入它们并使用它们?

如何编译项目?简单地使用javac?或者你用maven?或者某种IDE?基本答案是,依赖项必须在编译时和运行时都位于类路径上。“但这取决于您的环境,您如何实现这一点?”Balas Nemes简单地使用javac。实际上我使用了maven,但后来我只想使用javac并测试它。所以我想坚持使用javac!你能详细说明一下我提供的背景吗!您可以使用
javac-cp
选项将目录添加到类路径。在您的例子中,jmh类的根目录是src目录,因此您应该尝试类似的方法:
javac-cp src JMHSortBenchmark.java
I执行了以下“jar-cvf-src/main/java/lib/incall.jar-C-src/main/java/org”“javac-cpc:/Windows/System32/first benchmark/src/main/java/lib/incall.jar;。JMHSortBenchmark.java”,但仍然显示相同的错误@Balázsnees