ant -f build.xml run 与 ant -f build jar

发布于 12-11 06:34 字数 5480 浏览 0 评论 0原文

谁能告诉我

1-

ant -f build.xml run 

2-

ant -f build.xml jar
java -jar project.jar

之间的技术区别是什么?我问这个是因为我的应用程序运行完美,我使用数字“1”命令运行它

,但

在运行时出现了很多异常作为 jar 文件(2 号命令集)。

这有什么解释吗??我只是想知道为什么应用程序对这两种情况的反应不同???!

谢谢

<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="LMB" default="default" basedir=".">
    <description>Builds, tests, and runs the project LMB.</description>
    <import file="nbproject/build-impl.xml"/>
    <!--

    There exist several targets which are by default empty and which can be 
    used for execution of your tasks. These targets are usually executed 
    before and after some main targets. They are: 

      -pre-init:                 called before initialization of project properties
      -post-init:                called after initialization of project properties
      -pre-compile:              called before javac compilation
      -post-compile:             called after javac compilation
      -pre-compile-single:       called before javac compilation of single file
      -post-compile-single:      called after javac compilation of single file
      -pre-compile-test:         called before javac compilation of JUnit tests
      -post-compile-test:        called after javac compilation of JUnit tests
      -pre-compile-test-single:  called before javac compilation of single JUnit test
      -post-compile-test-single: called after javac compilation of single JUunit test
      -pre-jar:                  called before JAR building
      -post-jar:                 called after JAR building
      -post-clean:               called after cleaning build products

    (Targets beginning with '-' are not intended to be called on their own.)

    Example of inserting an obfuscator after compilation could look like this:

        <target name="-post-compile">
            <obfuscate>
                <fileset dir="${build.classes.dir}"/>
            </obfuscate>
        </target>

    For list of available properties check the imported 
    nbproject/build-impl.xml file. 


    Another way to customize the build is by overriding existing main targets.
    The targets of interest are: 

      -init-macrodef-javac:     defines macro for javac compilation
      -init-macrodef-junit:     defines macro for junit execution
      -init-macrodef-debug:     defines macro for class debugging
      -init-macrodef-java:      defines macro for class execution
      -do-jar-with-manifest:    JAR building (if you are using a manifest)
      -do-jar-without-manifest: JAR building (if you are not using a manifest)
      run:                      execution of project 
      -javadoc-build:           Javadoc generation
      test-report:              JUnit report generation

    An example of overriding the target for project execution could look like this:

        <target name="run" depends="iDA-impl.jar">
            <exec dir="bin" executable="launcher.exe">
                <arg file="${dist.jar}"/>
            </exec>
        </target>

    Notice that the overridden target depends on the jar target and not only on 
    the compile target as the regular run target does. Again, for a list of available 
    properties which you can use, check the target you are overriding in the
    nbproject/build-impl.xml file. 

    -->
</project>

,这是清单文件

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0-b147 (Oracle Corporation)
Class-Path: lib/beansbinding-1.2.1.jar lib/AbsoluteLayout.jar lib/appf
 ramework-1.0.3.jar lib/swing-worker-1.1.jar lib/swing-layout-1.0.4.ja
 r lib/commons-codec-1.4.jar lib/commons-codec-1.5.jar lib/commons-log
 ging-1.1.1.jar lib/derby.jar lib/derbyLocale_cs.jar lib/derbyLocale_d
 e_DE.jar lib/derbyLocale_es.jar lib/derbyLocale_fr.jar lib/derbyLocal
 e_hu.jar lib/derbyLocale_it.jar lib/derbyLocale_ja_JP.jar lib/derbyLo
 cale_ko_KR.jar lib/derbyLocale_pl.jar lib/derbyLocale_pt_BR.jar lib/d
 erbyLocale_ru.jar lib/derbyLocale_zh_CN.jar lib/derbyLocale_zh_TW.jar
  lib/derbyclient.jar lib/derbynet.jar lib/derbyrun.jar lib/derbytools
 .jar lib/httpclient-4.1.2.jar lib/httpclient-cache-4.1.2.jar lib/http
 core-4.1.2.jar lib/httpmime-4.1.2.jar lib/jdom.jar lib/orangevolt-ant
 -tasks-1.3.8.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: lmb.LMBApp

注意:
在这里我找到了这个问题的根源,但我不知道如何解决它,

关于库引用和环境变量的一切都很好,除了我在启动 jar 文件时没有获得到服务器的 SSL 连接,而从 Netbeans 内部运行应用程序时可以轻松建立连接。事实上,在执行最终的 jar 时,我遇到了以下异常,

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source)

请帮助我解决这个问题

Can anyone please tell me what is the technical difference between,

1-

ant -f build.xml run 

and

2-

ant -f build.xml jar
java -jar project.jar

I'm asking this because my application runs flawlessly with I run it with the number "1" command

BUT

Comes up with a whole lot of exceptions when is run as a jar file (Number 2 command set).

Any explanation for this??! I just want to know why the application responds differently to these two situations???!

Thanks

<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="LMB" default="default" basedir=".">
    <description>Builds, tests, and runs the project LMB.</description>
    <import file="nbproject/build-impl.xml"/>
    <!--

    There exist several targets which are by default empty and which can be 
    used for execution of your tasks. These targets are usually executed 
    before and after some main targets. They are: 

      -pre-init:                 called before initialization of project properties
      -post-init:                called after initialization of project properties
      -pre-compile:              called before javac compilation
      -post-compile:             called after javac compilation
      -pre-compile-single:       called before javac compilation of single file
      -post-compile-single:      called after javac compilation of single file
      -pre-compile-test:         called before javac compilation of JUnit tests
      -post-compile-test:        called after javac compilation of JUnit tests
      -pre-compile-test-single:  called before javac compilation of single JUnit test
      -post-compile-test-single: called after javac compilation of single JUunit test
      -pre-jar:                  called before JAR building
      -post-jar:                 called after JAR building
      -post-clean:               called after cleaning build products

    (Targets beginning with '-' are not intended to be called on their own.)

    Example of inserting an obfuscator after compilation could look like this:

        <target name="-post-compile">
            <obfuscate>
                <fileset dir="${build.classes.dir}"/>
            </obfuscate>
        </target>

    For list of available properties check the imported 
    nbproject/build-impl.xml file. 


    Another way to customize the build is by overriding existing main targets.
    The targets of interest are: 

      -init-macrodef-javac:     defines macro for javac compilation
      -init-macrodef-junit:     defines macro for junit execution
      -init-macrodef-debug:     defines macro for class debugging
      -init-macrodef-java:      defines macro for class execution
      -do-jar-with-manifest:    JAR building (if you are using a manifest)
      -do-jar-without-manifest: JAR building (if you are not using a manifest)
      run:                      execution of project 
      -javadoc-build:           Javadoc generation
      test-report:              JUnit report generation

    An example of overriding the target for project execution could look like this:

        <target name="run" depends="iDA-impl.jar">
            <exec dir="bin" executable="launcher.exe">
                <arg file="${dist.jar}"/>
            </exec>
        </target>

    Notice that the overridden target depends on the jar target and not only on 
    the compile target as the regular run target does. Again, for a list of available 
    properties which you can use, check the target you are overriding in the
    nbproject/build-impl.xml file. 

    -->
</project>

And here is the manifest file

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.7.0-b147 (Oracle Corporation)
Class-Path: lib/beansbinding-1.2.1.jar lib/AbsoluteLayout.jar lib/appf
 ramework-1.0.3.jar lib/swing-worker-1.1.jar lib/swing-layout-1.0.4.ja
 r lib/commons-codec-1.4.jar lib/commons-codec-1.5.jar lib/commons-log
 ging-1.1.1.jar lib/derby.jar lib/derbyLocale_cs.jar lib/derbyLocale_d
 e_DE.jar lib/derbyLocale_es.jar lib/derbyLocale_fr.jar lib/derbyLocal
 e_hu.jar lib/derbyLocale_it.jar lib/derbyLocale_ja_JP.jar lib/derbyLo
 cale_ko_KR.jar lib/derbyLocale_pl.jar lib/derbyLocale_pt_BR.jar lib/d
 erbyLocale_ru.jar lib/derbyLocale_zh_CN.jar lib/derbyLocale_zh_TW.jar
  lib/derbyclient.jar lib/derbynet.jar lib/derbyrun.jar lib/derbytools
 .jar lib/httpclient-4.1.2.jar lib/httpclient-cache-4.1.2.jar lib/http
 core-4.1.2.jar lib/httpmime-4.1.2.jar lib/jdom.jar lib/orangevolt-ant
 -tasks-1.3.8.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: lmb.LMBApp

NOTE:
Here I FOUND THE SOURCE OF THIS ISSUE BUT I DON'T KNOW HOW TO FIX IT,

Everything about library referencing and environment variables are ok except the fact that I'm not getting my SSL connection to the server while launching the jar file whereas the connection is easily made while running the application from inside Netbeans. In fact I'm getting this following Exception when executing through the final jar fine,

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source)

PLEASE HELP ME WITH THIS

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作妖2024-12-18 06:34:13

可能第一个使用编译(或执行)类路径,而第二个依赖于环境类路径(jar 不包含应用程序的所有依赖项)。

Likely the first one uses a compilation (or execution) classpath, while the second one relies on an environment classpath (the jar doesn't include all your app's dependencies).

窗影残2024-12-18 06:34:13

清单中的所有项目都需要添加到类路径调用中。

这可能包含依赖项 jar 的列表,您可以使用 -classpath 选项将其包含在命令行中。

java -cp gen/jars/test.jar -jar project.jar

您可以内联 Ant build.xml 和/或抛出的异常,以便我们可以为您提供更多信息。

All of the items in your manifest need to be added to the classpath call.

This may contain a list of dependency jars which you could include on the command line using the -classpath options

java -cp gen/jars/test.jar -jar project.jar

You could inline the Ant build.xml and/or exceptions thrown so we can give you more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文