Java命令行工具总结

摘要:
Java命令行工具摘要1。命令C/DocumentsandSettings/Zananed>

Java命令行工具总结

1、命令

C/Documents and Settings/Zianed>ls ‘%JAVA_HOME%’/bin

HtmlConverter.exe  javap.exe       jstatd.exe        rmid.exe

appletviewer.exe   javaw.exe       jvisualvm.exe     rmiregistry.exe

apt.exe            javaws.exe      keytool.exe       schemagen.exe

beanreg.dll        jconsole.exe    kinit.exe         serialver.exe

extcheck.exe       jdb.exe         klist.exe         servertool.exe

idlj.exe           jhat.exe        ktab.exe          tnameserv.exe

jar.exe            jinfo.exe       msvcr71.dll       unpack200.exe

jarsigner.exe      jli.dll         native2ascii.exe  wsgen.exe

java-rmi.exe       jmap.exe        orbd.exe          wsimport.exe

java.exe           jps.exe         pack200.exe       xjc.exe

javac.exe          jrunscript.exe  packager.exe

javadoc.exe        jstack.exe      policytool.exe

javah.exe          jstat.exe       rmic.exe

需要获得其中的帮助使用XX -help即可

Basic Tools

These tools are the foundation of the JDK. They are the tools you use to create and build applications.

Tool Name Brief Description Links to Reference Pages
javacThe compiler for the Java programming language.[Solaris and Linux ] [Windows ]
javaThe launcher for Java applications. In this release, a single launcher is used both for development and deployment.
The old deployment launcher, jre , is no longer provided.
[Solaris and Linux ] [Windows ]
javadocAPI documentation generator.
See Javadoc Tool page for doclet and taglet APIs.
[Solaris and Linux ] [Windows ]
aptAnnotation processing tool.
See Annotation Processing Tool for program annotation processing.
[Solaris, Linux, and Windows ]
appletviewerRun and debug applets without a web browser.[Solaris and Linux ] [Windows ]
jarCreate and manage Java Archive (JAR) files.
See Java Archive Files page for the JAR specification.
[Solaris and Linux ] [Windows ]
jdbThe Java Debugger.
See JPDA for the debugger architecture specifications.
[Solaris and Linux ] [Windows ]
javahC header and stub generator. Used to write native methods.[Solaris and Linux ] [Windows ]
javapClass file disassembler[Solaris and Linux ] [Windows ]
extcheckUtility to detect Jar conflicts.[Solaris and Linux ] [Windows ]

Security Tools

These security tools help you set security policies on your system and create apps that can work within the scope of security policies set at remote sites.

Tool Name Brief Description Links to Reference Pages
keytoolManage keystores and certificates.[Solaris and Linux ] [Windows ]
jarsignerGenerate and verify JAR signatures.[Solaris and Linux ] [Windows ]
policytoolGUI tool for managing policy files.[Solaris and Linux ] [Windows ]

These security tools help you obtain, list, and manage Kerberos tickets.

Tool Name Brief Description Links to Reference Pages
kinitTool for obtaining Kerberos v5 tickets. Equivalent functionality is available on the Solaris operating environment via the kinit tool. For example, for Solaris 8, see the kinit reference page .[Linux ] [Windows ]
klistCommand-line tool to list entries in credential cache and key tab. Equivalent functionality is available on the Solaris operating environment via the klist tool. For example, for Solaris 8, see the klist reference page .[Linux ] [Windows ]
ktabCommand-line tool to help the user manage entires in the key table. Equivalent functionality is available on the Solaris operating environment via the kadmin tool. For example, for Solaris 8, see the kadmin reference page .[Linux ] [Windows ]

Internationalization Tools

This tool helps to create localizable apps.

Tool Name Brief Description Links to Reference Pages
native2asciiConvert text to Unicode Latin-1.[Solaris and Linux ] [Windows ]

Remote Method Invocation (RMI) Tools

These tools help to create apps that interact over the Web or other network.

Tool Name Brief Description Links to Reference Pages
rmicGenerate stubs and skeletons for remote objects.[Solaris and Linux ] [Windows ]
rmiregistryRemote object registry service.[Solaris and Linux ] [Windows ]
rmidRMI activation system daemon.[Solaris and Linux ] [Windows ]
serialverReturn class serialVersionUID.[Solaris and Linux ] [Windows ]

Java IDL and RMI-IIOP Tools

These tools are used when creating applications that use OMG-standard IDL and CORBA/IIOP.

Tool Name Brief Description
tnameservProvides access to the naming service.
idljGenerates .java files that map an OMG IDL interface and enable an application written in the Java programming language to use CORBA functionality.
orbdProvides support for clients to transparently locate and invoke persistent objects on servers in the CORBA environment. ORBD is used instead of the Transient Naming Service, tnameserv. ORBD includes both a Transient Naming Service and a Persistent Naming Service. The orbd tool incorporates the functionality of a Server Manager, an Interoperable Naming Service, and a Bootstrap Name Server. When used in conjunction with the servertool, the Server Manager locates, registers, and activates a server when a client wants to access the server.
servertoolProvides ease-of-use interface for the application programmers to register, unregister, startup, and shutdown a server.

Java Deployment Tools

Utilities for use in conjunction with deployment of java applications and applets on the web.

Tool Name Brief Description
pack200Transforms a JAR file into a compressed pack200 file using the Java gzip compressor. The compressed packed files are highly compressed JARs, which can be directly deployed, saving bandwidth and reducing download time.
unpack200Transforms a packed file produced by pack200 into a JAR file.

Java Plug-in Tools

Utilities for use in conjunction with the Java Plug-in.

Tool Name Brief Description with Links to Reference Pages
htmlconverterConverts an HTML page (file) containing applets to the OBJECT / EMBED tag format for Java Plug-in.

Java Web Start Tools

Utilities for use in conjunction with the Java Web Start.

Tool Name Brief Description
javawsCommand line tool for launching Java Web Start and setting various options.
See Java Web Start Guide for more information.

Monitoring and Management Tools

You can use the following tools to monitor JVM performance and resource consumption. The tools described in this section are unsupported and experimental , and should be used with that in mind. They may not be available in future JDK versions.

Platform support:

  • jconsole: all platforms.
  • jps, jstat, and jstatd: all platforms except Windows 98 and Windows ME.

For more information, see Monitoring and Management for the Java Platform .

Tool Name Brief Description
jconsoleExperimental : Java Monitoring and Management Console – JMX-compliant graphical tool for monitoring a Java virtual machine. It can monitor both local and remote JVMs.
jpsExperimental : JVM Process Status Tool – Lists instrumented HotSpot Java virtual machines on a target system.
jstatExperimental : JVM Statistics Monitoring Tool – Attaches to an instrumented HotSpot Java virtual machine and collects and logs performance statistics as specified by the command line options.
jstatdExperimental : JVM jstat Daemon – Launches an RMI server application that monitors for the creation and termination of instrumented HotSpot Java virtual machines and provides a interface to allow remote monitoring tools to attach to Java virtual machines running on the local system.

Troubleshooting Tools

The following tools can be used for specific troubleshooting tasks. The tools described in this section are unsupported and experimental in nature and should be used with that in mind. They may not be available in future JDK versions.

These tools are not currently available on Windows platforms .

Tool Name Brief Description
jinfoExperimental – Configuration Info for Java – Prints configuration information for for a given process or core file or a remote debug server.
jmapExperimental – Memory Map for Java – Prints shared object memory maps or heap memory details of a given process or core file or a remote debug server.
jsadebugdExperimental – Serviceability Agent Debug Daemon for Java – Attaches to a process or core file and acts as a debug server.
jstackExperimental – Stack Trace for Java – Prints a stack trace of threads for a given process or core file or remote debug server.

2、命令简单介绍

2.1 HtmlConverter

2.2 appletviewer

查看Applet程序的运行结果。

2.3 apt

2.4 extcheck

2.5 idlj

2.6 jar

将一个文件打成jar包,以提供给给程序,方便使用。

bash-3.2$ jar -help

非法选项:h

用法: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files …

选项包括:

-c  创建新的归档文件

-t  列出归档目录

-x  解压缩已归档的指定(或所有)文件

-u  更新现有的归档文件

-v  在标准输出中生成详细输出

-f  指定归档文件名

-m  包含指定清单文件中的清单信息

-e  为捆绑到可执行 jar 文件的独立应用程序

指定应用程序入口点

-0  仅存储;不使用任何 ZIP 压缩

-M  不创建条目的清单文件

-i  为指定的 jar 文件生成索引信息

-C  更改为指定的目录并包含其中的文件

如果有任何目录文件,则对其进行递归处理。

清单文件名、归档文件名和入口点名的指定顺序

与 “m”、”f” 和 “e” 标志的指定顺序相同。

示例 1:将两个类文件归档到一个名为 classes.jar 的归档文件中:

jar cvf classes.jar Foo.class Bar.class

示例 2:使用现有的清单文件 “mymanifest” 并

将 foo/ 目录中的所有文件归档到 “classes.jar” 中:

jar cvfm classes.jar mymanifest -C foo/ .

bash-3.2$ jar -cvf zianed.jar *.class

标明清单(manifest)

增加:A.class(读入= 112) (写出= 105)(压缩了 6%)

增加:B.class(读入= 246) (写出= 184)(压缩了 25%)

bash-3.2$

2.7 jarsigner

2.8 java-rmi

2.9 java

执行java语言,期中包括了一部分的java执行可以使用和引入的参数;也包括了部分执行时的信息收集信息。

bash-3.2$ java -version

java version “1.6.0_10″

Java(TM) SE Runtime Environment (build 1.6.0_10-b33)

Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode)

2.10 javac

java编译器,将java源文件编译成可以供jvm执行的二进制class文件。

bash-3.2$ javac -version

javac 1.6.0_10

2.11 javadoc

根据源文件生成java的doc文档API。

2.12 javah

bash-3.2$ cd zianed

bash-3.2$ ls B.*

B.class  B.java

bash-3.2$ cd ..

bash-3.2$ javah zianed.B

bash-3.2$ ls

zianed  zianed_B.h

bash-3.2$

2.13 javap

将java字节码文件进行反编译的工具。

bash-3.2$ javap zianed.B

Compiled from “B.java”

public class zianed.B extends java.lang.Object implements zianed.A{

public zianed.B();

public void print();

public native java.lang.String getInfo();

}

bash-3.2$

2.14 javaw

The javaw command is identical to java , except that with javaw there is no associated console window. Use javaw when you don’t want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.

2.15 javaws:

2.16 jconsole

Java Monitoring and Management Console

启动java进程监控和管理控制台。监控和分析jvm的运行情况。

用法: jconsole [ -interval=n ] [ -notile ] [ -pluginpath <path> ] [ -version ] [ connection ...]

-interval   将更新间隔时间设置为 n 秒(默认值为 4 秒)

-notile     最初不平铺显示窗口(对于两个或更多连接)

-pluginpath 指定 jconsole 用于查找插件的路径

-version    输出程序版本

connection = pid || host:port || JMX URL (service:jmx:<protocol>://…)

pid       目标进程的进程 ID

host      远程主机名或 IP 地址

port      用于远程连接的端口号

-J        对正在运行 jconsole 的 Java 虚拟机指定输入参数

2.17 jdb

2.18 jhat

2.19 jinfo

2.20 jmap

2.21 jps

列出当前正在运行的Java程序。

Java Virtual Machine Process Status Tool

The jps command will report the local VM identifier, or lvmid , for each instrumented JVM found on the target system. The lvmid is typically, but not necessarily, the operating system’s process identifier for the JVM process.

参数说明:

-q

Suppress the output of the class name, JAR file name, and arguments passed to the main method, producing only a list of local VM identifiers.

-m

Output the arguments passed to the main method. The output may be null for embedded JVMs.

-l

Output the full package name for the application’s main class or the full path name to the application’s JAR file.

-v

Output the arguments passed to the JVM.

-V

Output the arguments passed to the JVM through the flags file (the .hotspotrc file or the file specified by the -XX:Flags=<filename > argument).

-Joption

Pass option to the java launcher called by javac . For example, -J-Xms48m sets the startup memory to 48 megabytes. It is a common convention for -J to pass options to the underlying VM executing applications written in Java.

bash-3.2$ jps -help

usage jps [-help]

jps [-q] [-mlvV] [<hostid>]

Definitions

<hostid>      <hostname>[<port>]

bash-3.2$ jps

3080

1100 Jps

bash-3.2$ jps -l

3020

572 sun.tools.jps.Jps

bash-3.2$ jps -v

2744 Jps -Denv.class.path=.;E:/lib;D:/Program Files/Java/jdk1.6.0_10/lib;D:

6.0_10/lib/tools.jar; -Xms8m

3020  -Dosgi.requiredJavaVersion=1.5 -Xms40m -Xmx256m -XX:MaxPermSize=256M

2.22 jrunscript

bash-3.2$ jrunscript -help

Usage: jrunscript [options] [arguments...]

where [options] include:

-classpath <path>    Specify where to find user class files

-cp <path>           Specify where to find user class files

-D<name>=<value>     Set a system property

-J<flag>             Pass <flag> directly to the runtime system

-l <language>        Use specified scripting language

-e <script>          Evaluate given script

-encoding <encoding> Specify character encoding used by script files

-f <script file>     Evaluate given script file

-f -                 Interactive mode, read script from standard input

If this is used, this should be the last -f option

-help                Print this usage message and exit

-?                   Print this usage message and exit

-q                   List all scripting engines available and exit

If [arguments..] are present and if no -e or -f option is used, then first

argument is script file and the rest of the arguments, if any, are passed

as script arguments. If [arguments..] and -e or -f option is used, then all

[arguments..] are passed as script arguments. If [arguments..], -e, -f are

missing, then interactive mode is used.

bash-3.2$ jrunscript -q

Language ECMAScript 1.6 implemention “Mozilla Rhino” 1.6 release 2

bash-3.2$

2.23 jstack

Stack Trace

Options are mutually exclusive. Option, if used, should follow immediately after the command name.

jstack prints Java stack traces of Java threads for a given Java process or core file or a remote debug server.

bash-3.2$ jstack -help

Usage:

jstack [-l] <pid>

(to connect to running process)

Options:

-l  long listing. Prints additional information about locks

-h or -help to print this help message

2.24 jstat

Java Virtual Machine Statistics Monitoring Tool

The jstat tool displays performance statistics for an instrumented HotSpot Java virtual machine (JVM).

The jstat command supports two types of options, general options and output options . General options cause jstat to display simple usage and version information. Output options determine the content and format of the statistical output.

bash-3.2$ jstat -help

Usage: jstat -help|-options

jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:

<option>      An option reported by the -options option

<vmid>       Virtual Machine Identifier. A vmid takes the following form:

<lvmid>[@<hostname>[:<port>]]

Where <lvmid> is the local vm identifier for the target

Java virtual machine, typically a process id; <hostname> is

the name of the host running the target Java virtual machine;

and <port> is the port number for the rmiregistry on the

target host. See the jvmstat documentation for a more complete

description of the Virtual Machine Identifier.

<lines>       Number of samples between header lines.

<interval>    Sampling interval. The following forms are allowed:

<n>["ms"|"s">

Where <n> is an integer and the suffix specifies the units as

milliseconds(”ms”) or seconds(”s”). The default units are “ms”.

<count>       Number of samples to take before terminating.

-J<flag>      Pass <flag> directly to the runtime system.

bash-3.2$ jstat -options

-class

-compiler

-gc

-gccapacity

-gccause

-gcnew

-gcnewcapacity

-gcold

-gcoldcapacity

-gcpermcapacity

-gcutil

-printcompilation

bash-3.2$ jps

2560 Jps

2308 JConsole

3020

bash-3.2$ jstat -gcutil -t 2308

Timestamp         S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT

522.9   0.00  91.47   1.88  34.29  72.17     11    0.034     0    0.000    0.034

bash-3.2$

bash-3.2$ jstat -class -t -h2 2308 500 8[ 间隔500ms运行8次]

Timestamp       Loaded  Bytes  Unloaded  Bytes     Time

1032.7   1634  1977.6        0     0.0       0.40

1033.3   1634  1977.6        0     0.0       0.40

Timestamp       Loaded  Bytes  Unloaded  Bytes     Time

1033.8   1634  1977.6        0     0.0       0.40

1034.3   1634  1977.6        0     0.0       0.40

Timestamp       Loaded  Bytes  Unloaded  Bytes     Time

1034.8   1634  1977.6        0     0.0       0.40

1035.3   1634  1977.6        0     0.0       0.40

Timestamp       Loaded  Bytes  Unloaded  Bytes     Time

1035.8   1634  1977.6        0     0.0       0.40

1036.2   1634  1977.6        0     0.0       0.40

bash-3.2$

2.25 jstatd

Virtual Machine jstat Daemon

The jstatd tool is an RMI server application that monitors for the creation and termination of instrumented HotSpot Java virtual machines (JVMs) and provides a interface to allow remote monitoring tools to attach to JVMs running on the local host.

bash-3.2$ jstatd –help

Virtual Machine jstat Daemon

usage: jstatd [-nr] [-p port] [-n rminame]

2.26 jvisualvm

启动VisualVM查看VM状态。

bash-3.2$ jvisualvm &

[1] 3660

bash-3.2$

2.27 keytool

2.28 kinit

2.29 klist

2.30 ktab

2.31 native2ascii

对文件转换编码。

用法:native2ascii [-reverse] [-encoding 编码] [输入文件 [输出文件]]

2.32 orbd

2.33 pack200

2.34 packager

2.35 polocytool

2.36 rmic

2.37 rmid

2.38 rmiregisty

2.39 schemagen

2.40 serialver

2.41 servertool

2.42  tnameserv

2.43  unpack200

2.44  wsgen

2.45  wsimport

2.46  xjc

3、jvm的部分参数

也就是在启动Java虚拟机、或者执行JAVA时应该添加的程序。

Windows平台下在以下路径下存在参数说明。

-Xmixed           mixed mode execution (default)

-Xint             interpreted mode execution only

-Xbootclasspath<directories and zip/jar files separated by ;>

set search path for bootstrap classes and resources

-Xbootclasspath/a<directories and zip/jar files separated by ;>

append to end of bootstrap class path

-Xbootclasspath/p<directories and zip/jar files separated by ;>

prepend in front of bootstrap class path

-Xnoclassgc       disable class garbage collection

-Xincgc           enable incremental garbage collection

-Xloggc<file>    log GC status to a file with time stamps

-Xbatch           disable background compilation

-Xms<size>        set initial Java heap size

-Xmx<size>        set maximum Java heap size

-Xss<size>        set java thread stack size

-Xprof            output cpu profiling data

-Xfuture          enable strictest checks, anticipating future default

-Xrs              reduce use of OS signals by Java/VM (see documentation)

-Xcheckjni       perform additional checks for JNI functions

-Xshareoff          do not attempt to use shared class data

-Xshareauto      use shared class data if possible (default)

-Xshareon       require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.

5、最常用的工具

1)javac Java源代码编译工具

6、部分与优化相关的程序说明

免责声明:文章转载自《Java命令行工具总结》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Ubuntu telnetjsp弹出新窗口代码下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

C++库大全

基础类 1、 Dinkumware C++ Library 参考站点:http://www.dinkumware.com P.J. Plauger编写的高品质的标准库。P.J. Plauger博士是Dr. Dobb's程序设计杰出奖的获得者。其编写的库长期被Microsoft采用,并且最近Borland也取得了其OEM的license,在其C/C+ +的产品...

一、Windows下Git的安装与配置

一、下载Git安装包   1、打开Git的官方网站:https://git-scm.com/   2、找到下载页:https://git-scm.com/downloads   3、找到Windows版本下载页面:https://git-scm.com/download/win   4、因为准备使用TortoiseGit做图形客户端,所以就不选择Git G...

如何查看和修改Windows远程桌面端口

Windows远程桌面的默认端口为3389。基于安全性考虑,部分用户有修改默认端口的需要,以减少通过远程桌面恶意攻击和扫描主机的次数。 因此今天带大家一起学习下,如何查看和修改Windows远程桌面的默认端口。 一、查看Windows远程桌面端口 整体思路:根据进程查端口号 1)查看远程桌面服务TermService进程PID 选择 开始 > 运行...

集成WPF与Windows窗体

下载source - 1.92 MB 介绍 本文讨论如何将WPF XPS文档查看器集成到Windows窗体应用程序中。 “WPF给我们带来了一个美好的未来,我们都应该开始使用它,把我们所有的产品都换成它。” 这是个好主意,但对我们大多数人来说,这是不可能的。例如,我们的主要产品有成千上万行代码和数百个表单。把所有这些都扔进垃圾桶,然后重新开始,这将是经济上...

MFC入门(一)

Windows消息机制 基本概念解释 1) SDK和API SDK:软件开发工具包(Software Development Kit),一般都是一些被软件工程师用于为特定的软件包、软件框架、硬件平台、操作系统等建立应用软件的开发工具的集合。 API函数: Windows操作系统提供给应用程序编程的接口(Application Programming Int...

Docker Toolbox安装

公司最近搭建docker环境,其中会遇到一些问题,在这里记录一下。 先来了解一下docker 一、基本概念 1.Docker中基本概念镜像(Image)  提到镜像,有对操作系统有一定认知的都知道,镜像是一个压缩的ISO文件,里面包含操作系统运行所需要的运行环境以及库文件,配置文件等等。从认识上简单的来说,镜像就是面向对象中的类,相当于一个模板。从本质上来...