如何将一组 .java 文件转换为一个工作项目
我是一个疯狂的 Java 初学者,仅供参考。
我想编译一个使用这些文件中的 org.json 包的程序(实际上是为了回答一个 SO 问题): http://json.org/java/
我在 NetBeans 中创建了一个基本的 Java 应用程序,但是我该如何做让这些成为我的主类可以识别的类文件,并且它们可以相互识别。我是否需要以某种方式将它们打包并将它们放入项目的类路径中?我可以将它们与主类一起放入我的 src 文件中吗?
I am a crazy Java beginner, FYI.
I want to compile a program (actually to answer an SO question) that uses the org.json package in these files:
http://json.org/java/
I created a basic Java application in NetBeans, but how do I get these to be class files that my main class recognizes, and that they recognize each other. Do I need to jar them somehow and put them in the project's classpath? Can I just slap them in my src file along with the main class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用它们创建一个 jar 并将其添加到类路径中。
您也可以将它们放在 src 文件夹中,但需要遵守目录结构。这意味着文件应放置在如下文件夹中:
You can create a jar with them and add it to the classpath.
You can also put them in the src folder, but you need to honour the directory structure. This means that the files should be placed in a folder like this:
如果您不打算分叉和修改
org.json
包,最好将其用作 jar。使用 netbeans 将其添加到类路径的最简单方法:If you don't plan of forking and modifying the
org.json
package, it is better to use it as a jar. The easiest way to add it to the classpath with netbeans: