频道栏目
首页 > 程序开发 > 软件开发 > 其他 > 正文
Javac 与 Java CommandLine Operations解析
2018-09-17 11:18:35      个评论      
收藏   我要投稿

Javac

javac[ options ] [ sourcefiles ] [ classes ] [ @argfiles ]

Arguments may be in any order.

options

Command-line options.

sourcefiles

One or more source files to be compiled (such as MyClass.java).

classes

One or more classes to be processed for annotations (such as MyPackage.MyClass).

@argfiles

One or more files that lists options and source files. The-Joptions are not allowed in these files.

There are two ways to pass source code file names tojavac:

For a small number of source files, simply list the file names on the command line. For a large number of source files, list the file names in a file, separated by blanks or line breaks. Then use the list file name on thejavaccommand line, preceded by an@character.

Inner class definitions produce additional class files. These class files have names combining the inner and outer class names, such asMyClass$MyInnerClass.class.

You should arrange source files in a directory tree that reflects their package tree.The source code forcom.mysoft.mypack.MyClassshould be inC:\workspace\com\mysoft\mypack\MyClass.java.

You can specify a separate destination directory with-d.

-ddirectory

Set the destination directory for class files. The directory must already exist;javacwill not create it. If a class is part of a package,javacputs the class file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify-d C:\myclassesand the class is calledcom.mypackage.MyClass, then the class file is calledC:\myclasses\com\mypackage\MyClass.class.

If-dis not specified,javacputs each class files in the same directory as the source file from which it was generated.

Note:The directory specified by-dis not automatically added to your user class path.

Non-standard options begin with-X.

-cppathor-classpathpath

Specify where to find user class files, and (optionally) annotation processors and source files. This class path overrides the user class path in theCLASSPATHenvironment variable. If neitherCLASSPATH,-cpnor-classpathis specified, the user class path consists of the current directory.

If the-sourcepathoption is not specified, the user class path is also searched for source files.

If the-processorpathoption is not specified, the class path is also searched for annotation processors.

Setting the class path

The class path is the path that the Java runtime environment searches for classes and other resource files.

classpath1;classpath2

Class paths to the .jar, .zip or .class files. Eachclasspathshould end with a filename or directory depending on what you are setting the class path to:

For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file. For .class files in an unnamed package, the class path ends with the directory that contains the .class files. For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).

Multiple path entries are separated by semi-colons. With thesetcommand, it's important to omit spaces from around the equals sign (=).

The default class path is the current directory. Setting theCLASSPATHvariable or using the-classpathcommand-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

Classpath entries that are neither directories nor archives (.zip or .jar files) nor * are ignored.

-g

Generate all debugging information, including local variables. By default, only line number and source file information is generated.

-g:none

Do not generate any debugging information.

-g:{keyword list}

Generate only some kinds of debugging information, specified by a comma separated list of keywords. Valid keywords are:

source

Source file debugging information

lines

Line number debugging information

vars

Local variable debugging information

-Joption

Passoptionto thejavalauncher called byjavac. For example,-J-Xms48msets the startup memory to 48 megabytes. It is a common convention for-Jto pass options to the underlying VM executing applications written in Java.

Note:CLASSPATH,-classpath,-bootclasspath, and-extdirsdonotspecify the classes used to runjavac. Fiddling with the implementation of the compiler in this way is usually pointless and always risky. If you do need to do this, use the-Joption to pass through options to the underlyingjavalauncher.

-sourcepathsourcepath

Specify the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by semicolons (;) and can be directories, JAR archives, or ZIP archives. If packages are used, the local path name within the directory or archive must reflect the package name.

Note:Classes found through the class path may be subject to automatic recompilation if their sources are also found.

Java

java[options]classname[args]

options

Command-line options separated by spaces. SeeOptions.

classname

The name of the class to be launched.

filename

The name of the Java Archive (JAR) file to be called. Used only with the-jaroption.

args

The arguments passed to themain()method separated by spaces.

点击复制链接 与好友分享!回本站首页
上一篇:DOM4J解析
下一篇:C# 中的委托和事件(简单易懂的讲解)
相关文章
图文推荐
点击排行

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站