设置蚂蚁引导类路径:JDK 1.7 有一个新的 javac 警告,用于设置没有引导类路径的旧源 [英] Set ant bootclasspath: JDK 1.7 has a new javac warning for setting an older source without bootclasspath

查看:26
本文介绍了设置蚂蚁引导类路径:JDK 1.7 有一个新的 javac 警告,用于设置没有引导类路径的旧源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何结合-source 1.5 -target 1.5 设置ant bootclasspath?

How do I set the ant bootclasspath in conjunction with -source 1.5 -target 1.5?

这怎么可能不是 1.5 JDK 的硬编码路径?是否可以将环境变量设置为 bootclasspath 类似于如何从 ant 中使用 JAVA_HOME?

How can this not be a hardcoded path to the 1.5 JDK? Can I set an environment variable to bootclasspath similar to how JAVA_HOME can be used from ant?

理想情况下,我想做一些事情,例如设置环境变量或将参数传递给 ant.

Ideally I would like to do something like set an environment variable or pass an argument to ant.

推荐答案

以下说明了如何从环境变量中获取 Java 5 引导类位置,然后使用它.

Here's an illustration of how you might fetch the Java 5 boot classes location from an environment variable, then use it.

首先,设置环境变量——比如JAVA5_BOOTCLASSES.property 任务 使您可以访问环境,然后是 javacbootclasspath 参数任务将设置传递给编译器.

First, set the environment variable - say JAVA5_BOOTCLASSES. The property task gives you access to the environment, then the bootclasspath argument of the javac task passes the setting to the compiler.

<property environment="env" />
<property name="java5.boot.classpath" value="${env.JAVA5_BOOTCLASSES}" />

<javac source="1.5" target="1.5"
       bootclasspath="${java5.boot.classpath}"
       ...
/>

请注意,如果未设置环境变量,Ant 将忽略它并继续执行 - 因此编译器将回退到默认引导类路径.

Note that if the environment variable is not set, Ant will ignore it and proceed without - so the compiler will fall back to the default boot classpath.

如果合适,另一种选择是关闭警告,不要理会引导类路径.类似的东西

Another option, if appropriate, is to switch off the warnings, and not bother with the bootclasspath. Something like

<javac srcdir= ... >
    <compilerarg arg="-Xlint:-options" />
</javac>

但这可能会让您暴露在一些细微的错误中.

But that's likely to expose you to some subtle bugs.

这篇关于设置蚂蚁引导类路径:JDK 1.7 有一个新的 javac 警告,用于设置没有引导类路径的旧源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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