<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 51, comments - 17, trackbacks - 0, articles - 9
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    ant 編譯java程序簡介

    Posted on 2007-01-31 20:12 chenweicai 閱讀(1298) 評論(0)  編輯  收藏

    Java

    Description

    Executes a Java class within the running (Ant) VM or forks another VM if specified.

    If odd things go wrong when you run this task, set fork="true" to use a new JVM.

    As of Ant 1.6.3, you can interact with a forked VM, as well as sending input to it via the input and inputstring attributes.

    Parameters

    Attribute Description Required
    classname the Java class to execute. Either jar or classname
    jar the location of the jar file to execute (must have a Main-Class entry in the manifest). Fork must be set to true if this option is selected. See notes below for more details. Either jar or classname
    args the arguments for the class that is executed. deprecated, use nested <arg> elements instead. No
    classpath the classpath to use. No
    classpathref the classpath to use, given as referenceto a PATH defined elsewhere. No
    fork if enabled triggers the class execution in another VM (disabled by default) No
    spawn if enabled allows to start a process which will outlive ant.
    Requires fork=true, and not compatible with timeout, input, output, error, result attributes.
    (disabled by default)
    No
    jvm the command used to invoke the Java Virtual Machine, default is 'java'. The command is resolved by java.lang.Runtime.exec(). Ignored if fork is disabled. No
    jvmargs the arguments to pass to the forked VM (ignored if fork is disabled). deprecated, use nested <jvmarg> elements instead. No
    maxmemory Max amount of memory to allocate to the forked VM (ignored if fork is disabled) No
    failonerror Stop the buildprocess if the command exits with a returncode other than 0. Default is "false" (see note) No
    resultproperty The name of a property in which the return code of the command should be stored. Only of interest if failonerror=false and if fork=true. No
    dir The directory to invoke the VM in. (ignored if fork is disabled) No
    output Name of a file to which to write the output. If the error stream is not also redirected to a file or property, it will appear in this output. No
    error The file to which the standard error of the command should be redirected. No
    logError This attribute is used when you wish to see error output in Ant's log and you are redirecting output to a file/property. The error output will not be included in the output file/property. If you redirect error with the "error" or "errorProperty" attributes, this will have no effect. No
    append Whether output and error files should be appended to or overwritten. Defaults to false. No
    outputproperty The name of a property in which the output of the command should be stored. Unless the error stream is redirected to a separate file or stream, this property will include the error output. No
    errorproperty The name of a property in which the standard error of the command should be stored. No
    input A file from which the executed command's standard input is taken. This attribute is mutually exclusive with the inputstring attribute No; default is to take standard input from console (unless spawn="true")
    inputstring A string which serves as the input stream for the executed command. This attribute is mutually exclusive with the input attribute. No; default is to take standard input from console (unless spawn="true")
    newenvironment Do not propagate old environment when new environment variables are specified. Default is "false" (ignored if fork is disabled). No
    timeout Stop the command if it doesn't finish within the specified time (given in milliseconds). It is highly recommended to use this feature only if fork is enabled. No
    clonevm If set to true true, then all system properties and the bootclasspath of the forked Java Virtual Machine will be the same as those of the Java VM running Ant. Default is "false" (ignored if fork is disabled). since Ant 1.7 No

    Parameters specified as nested elements

    arg and jvmarg

    Use nested <arg> and <jvmarg> elements to specify arguments for the Java class and the forked VM respectively. See Command line arguments.

    sysproperty

    Use nested <sysproperty> elements to specify system properties required by the class. These properties will be made available to the VM during the execution of the class (either ANT's VM or the forked VM). The attributes for this element are the same as for environment variables.

    syspropertyset

    You can specify a set of properties to be used as system properties with syspropertysets.

    since Ant 1.6.

    classpath

    Java's classpath attribute is a PATH like structureand can also be set via a nested classpath element.

    bootclasspath

    The location of bootstrap class files can be specified using this PATH like structure- will be ignored if fork is not true or the target VM doesn't support it (i.e. Java 1.1).

    since Ant 1.6.

    env

    It is possible to specify environment variables to pass to the forked VM via nested env elements. See the description in the section about exec

    Settings will be ignored if fork is disabled.

    permissions

    Security permissions can be revoked and granted during the execution of the class via a nested permissions element. For more information please see permissions

    When the permission RuntimePermission exitVM has not been granted (or has been revoked) the System.exit() call will be intercepted and treated like indicated in failonerror.

    Note:
    If you do not specify permissions, a set of default permissions will be added to your Java invocation to make sure that the ant run will continue or terminated as indicated by failonerror. All permissions not granted per default will be checked by whatever security manager was already in place. exitVM will be disallowed.

    Settings will be ignored if fork is enabled.

    since Ant 1.6.

    assertions

    You can control enablement of Java 1.4 assertions with an <assertions>subelement.

    Assertion statements are currently ignored in non-forked mode.

    since Ant 1.6.

    redirector

    Since Ant 1.6.2

    A nested I/O Redirectorcan be specified. In general, the attributes of the redirector behave as the corresponding attributes available at the task level. The most notable peculiarity stems from the retention of the <java> attributes for backwards compatibility. Any file mapping is done using a null sourcefile; therefore not all Mappertypes will return results. When no results are returned, redirection specifications will fall back to the task level attributes. In practice this means that defaults can be specified for input, output, and error output files.

    Errors and return codes

    By default the return code of a <java> is ignored. Alternatively, you can set resultproperty to the name of a property and have it assigned to the result code (barring immutability, of course). When you set failonerror="true", the only possible value for resultproperty is 0. Any non-zero response is treated as an error and would mean the build exits.

    Similarly, if failonerror="false" and fork="false" , then <java>must return 0 otherwise the build will exit, as the class was run by the build JVM.

    JAR file execution

    The parameter of the jar attribute is of type File; that is, the parameter is resolved to an absolute file relative to the base directory of the project, not the directory in which the Java task is run. If you need to locate a JAR file relative to the directory the task will be run in, you need to explicitly create the full path to the JAR file.

    When using the jar attribute, all classpath settings are ignored according to Sun's specification.

    Examples

    				       <java classname="test.Main">
             <arg value="-h"/>
             <classpath>
               <pathelement location="dist/test.jar"/>
               <pathelement path="${java.class.path}"/>
             </classpath>
           </java>
    
    		
    Run a class in this JVM with a new jar on the classpath
    				       <java jar="dist/test.jar"
               fork="true"
               failonerror="true"
               maxmemory="128m"
               >
             <arg value="-h"/>
             <classpath>
               <pathelement location="dist/test.jar"/>
               <pathelement path="${java.class.path}"/>
             </classpath>
           </java>
    
    		
    Run the JAR test.jar in this project's dist/lib directory. using the manifest supplied entry point, forking (as required), and with a maximum memory of 128MB. Any non zero return code breaks the build.
    				       <java
               dir="${exec.dir}"
               jar="${exec.dir}/dist/test.jar"
               fork="true"
               failonerror="true"
               maxmemory="128m"
               >
             <arg value="-h"/>
             <classpath>
               <pathelement location="dist/test.jar"/>
               <pathelement path="${java.class.path}"/>
             </classpath>
           </java>
    
    		
    Run the JAR dist/test.jar relative to the directory ${exec.dir}, this being the same directory into which the JVM is to start up.
    				  <java classname="test.Main"/>
    		
    Runs a given class with the current classpath.
    				  <java classname="test.Main"
            fork="yes" >
        <sysproperty key="DEBUG" value="true"/>
        <arg value="-h"/>
        <jvmarg value="-Xrunhprof:cpu=samples,file=log.txt,depth=3"/>
      </java>
    
    		
    Add system properties and JVM-properties to the JVM as in java ="-Xrunhprof:cpu=samples,file=log.txt,depth=3 -DDEBUG=true test.Main
    				  <java classname="ShowJavaVersion" classpath="."
            jvm="path-to-java14-home/bin/java" fork="true"
            taskname="java1.4" >
    
    		
    Use a given Java implementation (another the one Ant is currently using) to run the class. For documentation in the log taskname is used to change the [java] log-prefix to [java1.4].

    Note: you can not specify the (highly deprecated) MSJVM, "jview.exe" as the JVM, as it takes different parameters for other JVMs, That JVM can be started from <exec> if required.


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 国产成人毛片亚洲精品| 亚洲精品美女在线观看| 在线日本高清免费不卡| 亚洲综合一区国产精品| 亚洲欧洲国产成人综合在线观看| 无码精品国产一区二区三区免费| 香蕉大伊亚洲人在线观看| 亚洲国产成人久久精品99| 免费国产污网站在线观看15 | 亚洲最大在线视频| 国产不卡免费视频| 91免费国产精品| 美女黄频a美女大全免费皮| 婷婷精品国产亚洲AV麻豆不片| 女人18毛片a级毛片免费| 插鸡网站在线播放免费观看| 午夜在线a亚洲v天堂网2019 | 免费看一级高潮毛片| 亚洲色av性色在线观无码| 免费女人18毛片a级毛片视频| 无码人妻一区二区三区免费看 | 狠狠亚洲狠狠欧洲2019| 91在线品视觉盛宴免费| A片在线免费观看| 国产精品亚洲一区二区三区在线观看 | 日韩高清在线高清免费| 久操免费在线观看| 人妻无码中文字幕免费视频蜜桃| 亚洲性69影院在线观看| 在线播放亚洲第一字幕| 国产免费人成在线视频| 亚洲人成人一区二区三区| 91大神免费观看| 两性色午夜免费视频| 国产精品亚洲一区二区在线观看| 亚洲伦理一区二区| 国产亚洲精品不卡在线| 免费一级成人毛片| 和日本免费不卡在线v| 最近免费mv在线观看动漫| av网站免费线看|