2012-12-13 27 views
1

我正在开发一个使用Netbeans RCP的应用程序。我已经添加了一个选项,一个罐子在project.properties文件我的平台,添加到我的类路径:如何自定义独立netbeans应用程序的java选项?

run.args.extra=-cp:a ./appclient/glassfish/lib/gf-client.jar 

我遇到的问题是不会当我从NetBeans IDE中运行它的工作,但不是当我尝试创建一个独立的应用程序(例如为Mac OSX构建)。我听说project.properties在运行独立应用程序时不再考虑在内,当然我的appclient包含jar的目录在应用程序包中不再存在(所以我的jar没有添加到类路径中)。

我该如何让这个-cp选项适用于我的独立Mac OSX应用程序?


编辑:我能够创建一个自定义的conf文件为我的独立平台,但我不能找到一种方法,我的jar添加到类路径中,我不知道该怎么选择使用。

编辑:我发现我需要你认可的机制来实现它。所以我已经添加下面的命令来我app.conf文件:

J-Djava.endorsed.dirs=/Users/altanis/appclient/glassfish/lib/gf-client.jar 

但是,当我运行的.app(MAC应用程序),我得到这个错误:

-J-Djava.endorsed.dirs=/Users/altanis/appclient/glassfish/lib/gf-client.jar: No such file or directory 

的路径是正确的。我需要做些特别的事情让JVM意识到这一点吗?我跟着this教程和地方在评论中笔者说:

Right, but the package-appclient copies everything for you and you should be able to put it on the classpath using the endorsed mechanism. Unpack the jar created by that and add everything you need from there (the jars) to your application installer. Then you can use the endorsed (-J-Djava.endorsed.dirs=${GFCLIENT_PATH}) mechanism in your app.conf to put it on the application classpath. This way you should be able to deploy it together with your client.

回答

0

您必须添加条目Class-path到你的应用程序的MANIFEST.MF 例如

Class-Path: apache-commons-2.1.jar ejb-api-3.0.jar 

这一切jars应在根目录中申请
您的申请应该有下一个结构

MyApplication.jar 
/META-INF 
/META-INF/MANIFEST.MF 
/apache-commons-2.1.jar 
/ejb-api-3.0.jar 
/com/package/classes 

,或者您可以使用JDK的jar工具来创建一个jar
这里阅读更多Oracle doc

+0

我的应用程序没有任何清单文件创建模块的类型库。 – nathan

+0

@nathan你的应用程序的外观如何?编译jar文件中的类?你有可执行类吗?或者你在应用服务器上部署应用程序 – Ilya

+0

@llya它只是一个简单的netbeans rcp应用程序,没有任何花式,没有MANIFEST.MF。我编辑了这个问题,因为我发现了一些被称为支持机制的内容,可以帮助我实现我想要的内容。 – nathan

1

我认为,创建一个新的图书馆是更好的办法。

  1. 有需要的jar
  2. 在你的模块添加依赖关系创建模块(类型包裹库)