zoukankan      html  css  js  c++  java
  • javac命令详解(下)

    摘自http://blog.csdn.net/hudashi/article/details/7058999
    javac命令详解(下)                          
     
    -verbose
    冗长输出。开启该参数,你将看到编译器编译java源码的详细过程。
    比如,示例13:
    D:project est>javac -cp libUtil.zip -sourcepath src -verbose -d classes srcc
    om obin*.java
    [parsing started srccom obinHello.java]
    [parsing completed 31ms]
    [parsing started srccom obinPeople.java]
    [parsing completed 0ms]
    [search path for source files: src]
    [search path for class files: C:jdk1.6.0jrelib esources.jar,C:jdk1.6.0jre
    lib t.jar,C:jdk1.6.0jrelibsunrsasign.jar,C:jdk1.6.0jrelibjsse.jar,C:jd
    k1.6.0jrelibjce.jar,C:jdk1.6.0jrelibcharsets.jar,C:jdk1.6.0jreclasses,
    C:jdk1.6.0jrelibextdnsns.jar,C:jdk1.6.0jrelibextlocaledata.jar,C:jdk1
    .6.0jrelibextsunjce_provider.jar,C:jdk1.6.0jrelibextsunmscapi.jar,C:jd
    k1.6.0jrelibextsunpkcs11.jar,libUtil.zip]
    [loading srccomhubinUtil.java]
    [parsing started srccomhubinUtil.java]
    [parsing completed 0ms]
    [loading javalangObject.class(javalang:Object.class)]
    [loading javalangString.class(javalang:String.class)]
    [checking com.robin.Hello]
    [loading javalangThread.class(javalang:Thread.class)]
    [wrote classescom obinHello.class]
    [checking com.robin.People]
    [wrote classescom obinPeople.class]
    [checking com.hubin.Util]
    [wrote classescomhubinUtil.class]
    [total 578ms]
    D:project est>javac -cp libUtil.zip -sourcepath src -verbose -d classes srccom obin*.java
    [parsing started srccom obinHello.java]
    [parsing completed 16ms]
    [parsing started srccom obinPeople.java]
    [parsing completed 0ms]
    [search path for source files: src]
    [search path for class files: C:jdk1.6.0jrelib esources.jar,C:jdk1.6.0jre
    lib t.jar,C:jdk1.6.0jrelibsunrsasign.jar,C:jdk1.6.0jrelibjsse.jar,C:jd
    k1.6.0jrelibjce.jar,C:jdk1.6.0jrelibcharsets.jar,C:jdk1.6.0jreclasses,
    C:jdk1.6.0jrelibextdnsns.jar,C:jdk1.6.0jrelibextlocaledata.jar,C:jdk1
    .6.0jrelibextsunjce_provider.jar,C:jdk1.6.0jrelibextsunmscapi.jar,C:jd
    k1.6.0jrelibextsunpkcs11.jar,libUtil.zip]
    [loading srccomhubinUtil.java]
    [parsing started srccomhubinUtil.java]
    [parsing completed 0ms]
    [loading javalangObject.class(javalang:Object.class)]
    [loading javalangString.class(javalang:String.class)]
    [checking com.robin.Hello]
    [wrote classescom obinHello.class]
    [checking com.robin.People]
    [wrote classescom obinPeople.class]
    [checking com.hubin.Util]
    [wrote classescomhubinUtil.class]
    [total 172ms]
    D:project est>javac -cp lib-classes -sourcepath src -verbose -d classes srccom obin*.java
    [parsing started srccom obinHello.java]
    [parsing completed 47ms]
    [parsing started srccom obinPeople.java]
    [parsing completed 0ms]
    [search path for source files: src]
    [search path for class files: C:jdk1.6.0jrelib esources.jar,C:jdk1.6.0jre
    lib t.jar,C:jdk1.6.0jrelibsunrsasign.jar,C:jdk1.6.0jrelibjsse.jar,C:jd
    k1.6.0jrelibjce.jar,C:jdk1.6.0jrelibcharsets.jar,C:jdk1.6.0jreclasses,
    C:jdk1.6.0jrelibextdnsns.jar,C:jdk1.6.0jrelibextlocaledata.jar,C:jdk1
    .6.0jrelibextsunjce_provider.jar,C:jdk1.6.0jrelibextsunmscapi.jar,C:jd
    k1.6.0jrelibextsunpkcs11.jar,lib-classes]
    [loading lib-classescomhubinUtil.class]
    [loading javalangObject.class(javalang:Object.class)]
    [loading javalangString.class(javalang:String.class)]
    [checking com.robin.Hello]
    [wrote classescom obinHello.class]
    [checking com.robin.People]
    [wrote classescom obinPeople.class]
    [total 656ms]
    非标准选项
    -X
    使用该参数,可以显示所有的非标准选项的有关信息。
    示例14:
    C:Documents and Settingshubin>javac -X
      -Xlint                     Enable recommended warnings
      -Xlint:{all,cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,f
    inally,overrides,-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-pat
    h,-serial,-finally,-overrides,none}Enable or disable specific warnings
      -Xbootclasspath/p:<path>   Prepend to the bootstrap class path
      -Xbootclasspath/a:<path>   Append to the bootstrap class path
      -Xbootclasspath:<path>     Override location of bootstrap class files
      -Djava.ext.dirs=<dirs>     Override location of installed extensions
      -Djava.endorsed.dirs=<dirs>Override location of endorsed standards path
      -Xmaxerrs <number>         Set the maximum number of errors to print
      -Xmaxwarns <number>        Set the maximum number of warnings to print
      -Xstdout <filename>        Redirect standard output
      -Xprint                    Print out a textual representation of specified typ
    es
      -XprintRounds              Print information about rounds of annotation proces
    sing
      -XprintProcessorInfo       Print information about which annotations a process
    or is asked to process
      -Xprefer:{source,newer}    Specify which file to read when both a source file
    and class file are found for an implicitly compiled class
     
    These options are non-standard and subject to change without notice.
    -Xline:{关键字列表}
    通过该命令我们将看到你java源码文件的一些危险代码,关键字有:{all,cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,f
    inally,overrides,-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides,none},没有"-"前缀的表示开启,有的该前缀的表示关闭,all表示开启所有,none表示都不开启。
    示例16:
    D:project est>javac -cp libUtil.zip -sourcepath src -Xlint:all -d classes srccom obin*.java
    srccom obinHello.java:11: warning: [deprecation] destroy() in java.lang.Threa
    d has been deprecated
                    t.destroy();
                     ^
    srccom obinHello.java:12: warning: [divzero] division by zero
                    int i=1/0;
                            ^
    2 warnings
    -Xstdout <filename>
    javac命令信息输出流的默认将在当前控制台进行显示,我们可以用该参数进行重新定义。
    比如,示例17:
    D:project est>javac -cp libUtil.zip -sourcepath src -verbose -Xstdout 1.log -
    d classes srccom obin*.java
    这样我们在1.log文件中将看到;
    [parsing started srccom obinHello.java]
    [parsing completed 16ms]
    [parsing started srccom obinPeople.java]
    [parsing completed 0ms]
    [search path for source files: src]
    [search path for class files: C:jdk1.6.0jrelib esources.jar,C:jdk1.6.0jrelib t.jar,C:jdk1.6.0jrelibsunrsasign.jar,C:jdk1.6.0jrelibjsse.jar,C:jdk1.6.0jrelibjce.jar,C:jdk1.6.0jrelibcharsets.jar,C:jdk1.6.0jreclasses,C:jdk1.6.0jrelibextdnsns.jar,C:jdk1.6.0jrelibextlocaledata.jar,C:jdk1.6.0jrelibextsunjce_provider.jar,C:jdk1.6.0jrelibextsunmscapi.jar,C:jdk1.6.0jrelibextsunpkcs11.jar,libUtil.zip]
    [loading comhubinUtil.class(comhubin:Util.class)]
    [loading javalangObject.class(javalang:Object.class)]
    [loading javalangString.class(javalang:String.class)]
    [checking com.robin.Hello]
    [wrote classescom obinHello.class]
    [checking com.robin.People]
    [wrote classescom obinPeople.class]
    [total 204ms]
    -Xmaxerrs <number>  
    设置最多显示多少条编译错误
     -Xmaxwarns <number>        
    设置最多显示多少条编译警告
    其他一些Xlint选项暂时还不知道什么意思,一般也用得比较少,就打住了。
    -J选项
    将选项传给 javac 调用的 java 启动器。例如, -J-Xms48m 将启动内存设为 48 兆字节。虽然它不以 -X 开头,但它并不是 javac 的‘标准选项’。用 -J 将选项传给执行用 Java 编写的应用程序的虚拟机是一种公共约定。
    其他一些javac命令选项暂时还不知道什么意思,一般也用得比较少,就打住了。
    另外附前面的示例所用的java源码文件:
    srccom obinHello.java文件
    package com.robin;
    import com.hubin.Util;
    public class Hello{
    native String getHelloStringFromJni();
    People p=new People();
    final static String str=Util.getString();
    Hello()
    {
    Thread t=null;
    t.start();
    t.destroy();
    int i=1/0;
    long l=10;
    int n=(int)l;
    }
    }
    srccom obinPeole.java文件
    package com.robin;
    public class People
    {
    String name;
    }
    srccomhubinUtil.java文件
    package com.hubin;
    public class Util{
    public final static String getString()
    {
    return "Hi";
    }
    }
  • 相关阅读:
    exchange 2013 versions
    Outlook Web App Customization
    Using the FullCalendar Plugin in SharePoint 2013 Apps
    erlide的调试设置
    MySQLProxy
    Flex Socket安全策略<policyfilerequest/>及应对方法
    一些flex教程
    CentOS apache 配置
    C++与Flex之间socket通信policyfilerequest解决方案
    免费使用Adobe Flash Builder 4.5方法
  • 原文地址:https://www.cnblogs.com/LiuYanYGZ/p/6054015.html
Copyright © 2011-2022 走看看