简体   繁体   English

如何查找 Netbeans 用于运行应用程序的命令

[英]How to find command Netbeans uses for run application

I have a project in Netbeans which uses Netbeans features I'm not familiar with, so I'm not sure how to move the build and run it elsewhere.我在 Netbeans 中有一个项目,它使用我不熟悉的 Netbeans 功能,所以我不确定如何移动构建并在其他地方运行它。

To open the project in Netbeans, I was told to do "File -> Project Groups -> New Group -> Free Group", then "File -> Open Project" and select the project.要在 Netbeans 中打开项目,我被告知执行“文件 -> 项目组 -> 新组 -> 自由组”,然后“文件 -> 打开项目”并选择项目。 This project has a lot of sub-projects (modules?).这个项目有很多子项目(模块?)。 The high-level one shows up with an icon that looks like 2 gold puzzle pieces, and I can open up module sub-projects inside of it which show up with grey puzzle piece icons.高级的会显示一个看起来像 2 个金色拼图块的图标,我可以打开其中的模块子项目,这些子项目显示为灰色拼图块图标。 I don't think the project is the NetBeans "Java Project" type.我不认为该项目是 NetBeans“Java 项目”类型。

To run it, I can right-click on the top-level gold-puzzle-piece project entry in the Projects panel and select "run".要运行它,我可以右键单击“项目”面板中的顶级金拼图项目条目,然后选择“运行”。 When I do that, it takes a while to build then it runs and all is well.当我这样做时,它需要一段时间来构建然后运行,一切都很好。

Now I want to move the updated software to a network share and run it on a different computer.现在我想将更新后的软件移动到网络共享并在另一台计算机上运行它。 I believe the other computer does not have NetBeans or jdk, just jre.我相信另一台计算机没有 NetBeans 或 jdk,只有 jre。

In the root of the project's directory is a nb_modules directory which contains nb_modules\\harness\\suite.xml which I think (not 100% sure) is the build xml.在项目目录的根目录中是一个 nb_modules 目录,其中包含 nb_modules\\harness\\suite.xml,我认为(不是 100% 确定)是构建 xml。 It has the following entry in it, in addition to others:除了其他条目外,它还有以下条目:

   <target name="run" depends="build,-jdk-init" description="Runs this suite in place.">
      <ant antfile="${harness.dir}/run.xml" target="run">
         <reference refid="cluster.path.id"/>
      </ant>
   </target>

The run.xml has the following target in it: run.xml 中有以下目标:

<target name="run" depends="-prepare-as-app,-prepare-as-platform">
    <touch file="${cluster}/.lastModified"/> <!-- #138427 -->
    <property name="run.args" value=""/>
    <property name="run.args.ide" value=""/>
    <property name="run.args.extra" value=""/>
    <condition property="run.args.mac" value="-J-Xdock:name='${app.name}'" else="">
        <os family="mac"/>
    </condition>
    <exec osfamily="windows" executable="${run.exe}" failonerror="no">
        <arg value="--jdkhome"/>
        <arg file="${run.jdkhome}"/>
        <arg line="${run.args.common}"/>
        <arg line="${run.args.prepared}"/>
        <arg line="${run.args}"/>
        <arg line="${run.args.extra}"/>
        <arg line="${run.args.ide}"/>
    </exec>
    <exec osfamily="unix" dir="." executable="sh" failonerror="no">
        <arg value="${run.sh}"/>
        <arg value="--jdkhome"/>
        <arg file="${run.jdkhome}"/>
        <arg line="${run.args.common}"/>
        <arg line="${run.args.prepared}"/>
        <arg line="${run.args}"/>
        <arg line="${run.args.extra}"/>
        <arg line="${run.args.mac}"/>
        <arg line="${run.args.ide}"/>
    </exec>
</target>

In the root of the project's directory I also have a build directory that I think is where stuff is getting build into, and it has a bunch of jars in it.在项目目录的根目录中,我还有一个构建目录,我认为它是构建内容的地方,里面有一堆 jar。 There is a …/build/cluster/modules/ directory with lots of jars and a …/build/cluster/core/locale/ directory there is only 1 file: core_app_all_gui.jar which I assume is the main jar.有一个 .../build/cluster/modules/ 目录,里面有很多 jar,一个 .../build/cluster/core/locale/ 目录只有 1 个文件:core_app_all_gui.jar,我认为它是主 jar。

If I try to do java -jar core_app_all_gui.jar I get "no main manifest attribute, in core_app_all_gui.jar", so I am wondering if maybe I need to do a java -cp core_app_all_gui.jar package.MainClass format perhaps.如果我尝试执行java -jar core_app_all_gui.jar我得到“在 core_app_all_gui.jar 中没有主要清单属性”,所以我想知道我是否需要执行java -cp core_app_all_gui.jar package.MainClass格式。 Since the suite.xml/run.xml aren't in the build area I'm not sure if I'm supposed to use them.由于suite.xml/run.xml 不在构建区域中,我不确定是否应该使用它们。 I assume they are ant scripts, though I'm not sure.我认为它们是蚂蚁脚本,但我不确定。 I'm not sure if the computer I want to run this on has ant or not.我不确定我想运行它的计算机是否有蚂蚁。

For my specific use case, if you can explain how to use the above xml data to help figure the command line that would work for me that would be fine.对于我的特定用例,如果您能解释如何使用上述 xml 数据来帮助确定对我有用的命令行,那就太好了。 It would be nice though to find a generic answer to the question which works for everyone.不过,找到对每个人都适用的问题的通用答案会很好。 All I want to do is to run it on a different computer.我想要做的就是在不同的计算机上运行它。

All other answers I find for this, including on StackOverflow, are specifically for conventional Netbeans Java projects which create a dist/myapp.jar that can be ran with simply java -jar myapp.jar .我为此找到的所有其他答案,包括在 StackOverflow 上,都专门针对传统的 Netbeans Java 项目,这些项目创建了一个 dist/myapp.jar,可以简单地使用java -jar myapp.jar Since that does not answer my question, they are not duplicates.由于这不能回答我的问题,因此它们不是重复的。

Your project looks like an ant project.您的项目看起来像一个蚂蚁项目。 It's difficult to figure out what command it uses for running just based on ant scripts.仅基于 ant 脚本很难弄清楚它用于运行的命令。 For ant project to check what command NetBeans uses for lunching applications go to Tools->Options->Java->Ant and set Verbosity level to Debug.对于要检查 NetBeans 用于午餐应用程序的命令的 ant 项目,请转到Tools->Options->Java->Ant并将Verbosity级别设置为 Debug。

After lunching your application from NetBeans you should look at the last command in output window (ctrl-4) or find the Executing keyword.从 NetBeans 处理您的应用程序后,您应该查看输出窗口 (ctrl-4) 中的最后一个命令或找到Executing关键字。

For example when running NetBeans in usual mode after compiling from source (NetBeans uses ant scripts) in output window I find this lines:例如,在输出窗口中从源代码(NetBeans 使用 ant 脚本)编译后以普通模式运行 NetBeans 时,我发现以下几行:

...
Current OS is Windows 10
Executing 'D:\GITHUB\OtherRepositoryes\NetBeans\nbbuild\netbeans\bin\netbeans64.exe' with arguments:
'--jdkhome'
'C:\Program Files\Java\jdk1.8.0_231'
'--userdir'
'D:\GITHUB\OtherRepositoryes\NetBeans\nbbuild\testuserdir'
'-J-Dnetbeans.full.hack=true'
The ' characters around the executable and arguments are
...

so to run it outside of ant scripts I just run:所以要在 ant 脚本之外运行它,我只需运行:

D:\GITHUB\OtherRepositoryes\NetBeans\nbbuild\netbeans\bin\netbeans64.exe --jdkhome "C:\Program Files\Java\jdk1.8.0_231\jre" --userdir D:\GITHUB\OtherRepositoryes\NetBeans\nbbuild\testuserdir -J-Dnetbeans.full.hack=true

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

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