简体   繁体   English

Java Eclipse构建路径

[英]Java Eclipse Build Path

Hi i write a Java Swing GUI that includes alot of .jar files. 嗨,我编写了一个Java Swing GUI,其中包含许多.jar文件。

I have add alot of .jar files to my Buildpath. 我在我的Buildpath中添加了很多.jar文件。 If now my friend trys to run the programm he got my Buildpath and they are wrong on his pc. 如果现在我的朋友尝试运行该程序,则他得到了我的Buildpath,而在他的PC上它们是错误的。

Is there a possible way to set the Buildpath so my friend don't have to set them again? 有没有可能设置Buildpath的方法,所以我的朋友不必再次设置它们?

for example at the moment one buildpath is like this: home/usr/bonzai/oad/xxx.jar 例如,当前一个构建路径是这样的:home / usr / bonzai / oad / xxx.jar

my programm that is executed is in the folder bonzai. 我执行的程序位于bonzai文件夹中。 so i want to set the path like this: ./oad/xxx.jar 所以我想这样设置路径:./oad/xxx.jar

So the programm knows go into the folder oad, that is in the same folder, then take xxx.jar. 因此,程序知道进入文件夹oad,即在同一文件夹中,然后取xxx.jar。

Hope you understand what i want to do :-) 希望你明白我想做什么:-)

mfg Christoph 制造克里斯托夫

I had this problem with using a project on Windows and Linux. 我在Windows和Linux上使用项目时遇到了这个问题。

  1. Go to Window->Preferences->Java->Build Path->Classpath Variables 转到窗口->首选项-> Java->构建路径->类路径变量
  2. Click "New", pick a name, like MY_PROJECT, and point to the project folder. 单击“新建”,选择一个名称,例如MY_PROJECT,然后指向项目文件夹。

When you include jar files, you do it a different way. 当包含jar文件时,您将以另一种方式进行操作。

  1. Project Properties->Java Build Path->Libraries (where you add jar files) 项目属性-> Java构建路径->库(在其中添加jar文件)
  2. To add, click "Add Variable" 要添加,请单击“添加变量”
  3. Select the MY_PROJECT variable you made and click "Extend". 选择您创建的MY_PROJECT变量,然后单击“扩展”。 Find the resource and add it to your project. 查找资源并将其添加到您的项目。

Now when anyone wants to use your project, they just have to do step 1 and 2. and point the MY_PROJECT classpath variable to where ever the folder is. 现在,当任何人想要使用您的项目时,他们只需执行步骤1和2,然后将MY_PROJECT类路径变量指向文件夹所在的位置即可。 It can be anywhere. 它可以在任何地方。 As long as the structure inside is the same, everything works. 只要内部结构相同,一切都可以正常工作。

This is how I share .project files with GIT. 这就是我与GIT共享.project文件的方式。 You can clone the project anywhere but everything works. 您可以在任何地方克隆项目,但一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM