英文:
How can I import a custom package in IntelliJ IDEA (Java)?
问题
有一个叫做CLASSPATH
的术语,它用于让JVM找到自定义类或jar
文件并将它们导入到其他包中(我理解正确吗?)。所以,我创建了一些自定义类并将它们放到了net.ederika
包中,然后我创建了另一个项目,命名为net.bartikan
包。我的主要想法是将net.ederika
包中的类导入到第二个项目中。我指定了CLASSPATH
环境变量CLASSPATH EV,并将带有扩展名.class
的文件添加到C:/DOC/JavaT net/edeirika/
文件夹中。我得到了这个错误:导入包时的错误。
我在这个过程中使用了IntelliJ IDEA。我的操作有什么问题吗?Bruce Eckel(《Java编程思想》一书的作者)写道,我们要指定CLASSPATH
,然后将不带.class
扩展名的文件夹添加到其中,JVM就会找到它们。我对这个主题感到非常沮丧和困惑,无法继续阅读那本书。来自《Java编程思想》。在互联网上关于这个问题的信息真的不多,因此我在这里提问。在CLASSPATH
指定的文件夹中的文件。
英文:
There is such term like CLASSPATH
which is using that JVM could find custom classes or jar
files to import them to another packages (Am I right?). So, I created a few custom classes and placed them into package net.ederika
, then I created another project with net.bartikan
package name. My main idea is to import classes from net.ederika
package to the second project. I specified CLASSPATH
environment variable CLASSPATH EV and added to C:/DOC/JavaT net/edeirika/
files with extension .class
. I got this: Error with package importing
I used IntelliJ IDEA for this. What's wrong with my actions? Bruce Eckel ("Thinking in Java" book) wrote that we specify CLASSPATH
, add there folders with out .class
files and JVM locates it. I'm really frustrated and confused with this topic and can't merely go on reading that book. From "Thinking in Java" There is no really much info about it on the Internet, thus I ask here. files in CLASSPATH
specified folders
答案1
得分: 0
IDEA: 文件 > 项目结构 > 库 > +
> Java > 选择库文件 > 确定 > 应用 > 确定
<h3>首先,在工具栏中找到“项目结构”</h3>
<h3>然后点击加号,表示添加您选择的外部项目库,我演示的是Java库</h3>
<h3>然后找到Java库文件路径,然后点击确定</h3>
<h3>最后,点击应用和确定</h3>
英文:
IDEA: File > Project Stucture > Libraries > +
> Java > Select Library Files > OK > Apply > OK
<h3>First, find Preject Structure in a file in the toolbar</h3>
<h3>Then click the plus sign, which means to add an external Project Library of your choice, where I am demonstrating the Java Library</h3>
<h3>Then find the Java Library file path and click OK</h3>
<h3>Finally, click Apply and ok</h3>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论