我怎么说Eclipse将我编译的包保存到另一个路径? [英] How do I say to Eclipse where to save my compiled packages to another path?

查看:354
本文介绍了我怎么说Eclipse将我编译的包保存到另一个路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有这个Java Eclipse项目,我使用自定义包:

So I have this Java Eclipse project where I use a custom package:


Project/
        src/
            defaultpackage/
                           *.jar
            mypackage/
                      class1.java, 
                      class2.java ...

如何在Eclipse中将所有 mypackage 类编译为 mypackage.jar 在另一个输出文件夹中?我知道默认情况下Eclipse会在项目目录中创建jar。

How do I say to Eclipse where to compile all mypackage classes as mypackage.jar in a different output folder? I know that by default Eclipse will create the jar's inside the project directory.

我的想法是为我的编译软件包提供一个文件夹,实际创建 myjarlib 文件夹,所以每次编译不同的包时都会创建一个 / ... / myjarlib / newpackage.jar 如果我为 newpackage 指定了这个。

My idea is to have a folder for my compiled packages out of the project structure, actually create myjarlib folder, so everytime I compile a different package will create a / ... / myjarlib / newpackage.jar only if I specified this for the newpackage.

推荐答案

在你的结构示例中,'src'文件夹是一个源文件夹。您可以配置eclipse在每个源文件夹的基础上发出build-on-save生成的类文件的位置。

In your structure example, the 'src' folder is a source folder. You can configure where eclipse emits the compile-on-save generated class files on a per-source-folder basis.

您无法在每个包的基础上配置它。

You cannot configure this on a per-package basis.

因此,在源文件夹级别更改它。如果您希望一个程序包进入目录A,另一个程序包进入目录B,请创建2个源文件夹,并为每个程序包进行配置。示例:

So, change it at the source folder level. If you want one package to go in directory A, and the other package to go to directory B, make 2 source folders, and configure for each. Example:

Project
    src
        main
            pkg1
                SomeJavaCode.java
        test
            pkg2
                SomeTestCode.java

这里是Project / src / main是一个源包(包含类pkg1.SomeJavaCode的源),与Project / src / test一样。右键单击项目并选择属性以修改哪些目录是源文件夹。同样在任何项目(不是源文件夹)的属性中,转到Java构建路径部分,选择源选项卡,单击要编辑的源文件夹,标记允许输出文件夹中的源文件夹 '选项(默认情况下,eclipse将所有源文件夹的编译保存结果发送到同一文件夹,此复选框允许您基于每个文件夹进行配置),并对其进行配置。

Here Project/src/main is a source package (containing the source for class pkg1.SomeJavaCode), as is Project/src/test. right click on the project and select 'properties' to modify which directory(ies) are source folders. Also in the 'properties' of any project (not the source folder), go to section 'Java Build Path', pick the "Source" tab, click on the sourcefolder you want to edit, mark the 'allow output folders for source folders' option (by default, eclipse sends the compile-on-save results of all source folders to the same folder, this checkbox lets you configure it on a per-folder basis), and configure it.

这篇关于我怎么说Eclipse将我编译的包保存到另一个路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆