Java BlueJ 导入自定义类库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20048222/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
BlueJ Importing custom class library
提问by Simon Jensen
Ok the deal is, I've made a small class library (*.Jar file) to help make a more visually organized code and to help with some common tasks.
好的,交易是,我制作了一个小型类库(*.Jar 文件)来帮助制作更具视觉效果的代码并帮助完成一些常见任务。
Before you tell me to go to: Tools > Preferences > Libraries. I have done that, over and over and over again.. I also tried to manually add it to: C:\Program Files\BlueJ\lib\userlib\"jar file here" And yes, i did restart BlueJ to load the newly added libraries.
在你告诉我去之前:工具 > 首选项 > 库。我一遍又一遍地这样做..我还尝试手动将它添加到:C:\Program Files\BlueJ\lib\userlib\"jar file here" 是的,我确实重新启动了 BlueJ 以加载新的添加了库。
No matter what i seem to try it won't let me import it to my project using the import command, but without it, it just won't compile.
无论我尝试什么,它都不会让我使用 import 命令将它导入到我的项目中,但没有它,它就无法编译。
I know i can just add the classes manually, but as the class library slowly grow, so does the effort of adding all the classes in that library.
我知道我可以手动添加类,但是随着类库的缓慢增长,在该库中添加所有类的工作也在增加。
In advance, thanks for your help and consideration.
在此先感谢您的帮助和考虑。
回答by Bill the Lizard
If adding your jar file in the Preferences > Libraries tab doesn't work, you can try adding the jar to the "userlib" directory at <bluej-dir>/lib/userlib
(where <bluej-dir>
is the folder where BlueJ was installed).
如果在 Preferences > Libraries 选项卡中添加 jar 文件不起作用,您可以尝试将 jar 添加到“userlib”目录中<bluej-dir>/lib/userlib
(<bluej-dir>
安装BlueJ的文件夹在哪里)。
A third option you can try is adding your jar file directly to a project by creating a +libs
directory inside your project directory and copying the jar to that directory. This has the drawback that you have to manually copy the jar to each project +libs
subfolder that needs your library. On the plus side, it allows you to distribute your project (library jars included) just by zipping up the root project directory.
您可以尝试的第三个选项是通过+libs
在项目目录中创建一个目录并将 jar 复制到该目录,将jar 文件直接添加到项目中。这有一个缺点,即您必须手动将 jar 复制到+libs
需要您的库的每个项目子文件夹中。从好的方面来说,它允许您仅通过压缩根项目目录来分发您的项目(包括库 jar)。
回答by Vadim Hapanchak
On Windows I create directory named "+libs" on my blueJ project directory, then add .jar to that directory, and restart blueJ , that′s help me, and import after that work fine
在 Windows 上,我在 blueJ 项目目录中创建名为“+libs”的目录,然后将 .jar 添加到该目录中,然后重新启动 blueJ ,这对我有帮助,然后导入后工作正常
回答by Harry Kar
Despite the post's oldness for who stumble upon i can say with the newest version of BlueJ (actually 4.1.3) in an old Ubuntu distro(Lucid Lynx aka 10.04LTS) all work as intended per default without any hack
尽管该帖子对于偶然发现的人来说已经很老了,但我可以说在旧的 Ubuntu 发行版(Lucid Lynx aka 10.04LTS)中使用最新版本的 BlueJ(实际上是 4.1.3)在默认情况下都按预期工作,没有任何黑客攻击