使用 ant 运行 NetBeans 项目 [英] Run NetBeans project just with ant

查看:31
本文介绍了使用 ant 运行 NetBeans 项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Netbeans 构建的示例代码.

I have a sample code that was built with Netbeans.

它有一个 build.xml 文件,所以我下载了 ant 并尝试运行它.

It has a build.xml file so I downloaded ant and try to run it.

我收到此错误消息:

...... nbproject\build-impl.xml:76: Platform is not correctly set up

据我所知,这是通过简单地"下载 Netbeans 并从那里运行示例来解决的,但是...我不想安装它来运行 10 个文件示例.

For what I can see, this is fixed by "simply" downloading Netbeans and running the sample from there, but... I don't want to install it to run a 10 files sample.

是否有使用 Java 运行 Netbeans 项目的解决方法?我必须修改的正确 .properties 文件是什么?

Is there a workaround to run Netbeans projects with Java? What's the correct .properties file I have to modify?

推荐答案

可以直接从 Java/ANT 运行 NetBeans 生成的项目,但您可能需要手动设置一些属性和/或添加 jar 文件的路径.

It is possible to run the NetBeans generated projects straight from Java/ANT, but you may need to manually set some of the properties and/or add paths to jar files.

不幸的是,NetBeans 倾向于使用它们自己的 JAR 文件和引用属性来包含 taskdef,这些属性仅在 /nbproject/private/private.properties 文件中定义,这些文件通常在您第一次打开NetBeans 项目或在 IDE 中编辑项目时进行修改.

Unfortunately, NetBeans tends to include taskdef's using their own JAR files and reference properties that are defined only in the /nbproject/private/private.properties files, which usually get set when you first open the NetBeans project or modified as you edit the project in the IDE.

如果您检查 build-impl.xml,您应该能够找到该属性并推导出需要设置的值(操作系统平台),然后:

If you inspect the build-impl.xml you should be able to find the property and derive what value needs to be set(OS platform), then either:

  • /nbproject/private.properties
  • 将该属性定义添加到父 build.xml
  • 在调用你的 ant 时传入命令行目标使用 -DPlatform=Foo

就我个人而言,我喜欢 NetBeans 生成的 ANT 文件和目标的结构,但讨厌它们塞入了多少自定义/专有的东西,这使得没有 NetBeans 很难运行.

Personally, I like the structure of the NetBeans generated ANT files and targets, but hate how much custom/proprietary stuff they jam in that makes it hard to run without NetBeans.

例如:

ant -Dplatforms.JDK_1.7.home=/opt/jdk 

这篇关于使用 ant 运行 NetBeans 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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