欢迎各位兄弟 发布技术文章
这里的技术是共享的
JSP能够让程序员在html当中嵌入java代码,从而实现基于java技术的动态网站开发,
程序员写的基于jsp技术所写的网页叫.jsp,jsp最终要转换成servlet,servlet能执行的程序都是java程序,只不过它是一种特殊的java类而已,,,,,,,,,,,,,,,,java类当中,像applet是一种特殊类,servlet也是一种特殊类,它们是用来开发应用在不同场景中的应用程序的,,,applet用来开发应用在客户端的应用程序,基于web技术?????servlet是基于cgi技术,能够运行在服务端的动态网站技术,,,,,,,,jsp将servlet的开发简化了,用户程序中只需要将jsp程序嵌入到html文档中就可以了,,,,事实上它们都是java的类(所谓的类,就是java的库, 类库),都是能够在各自的应用场景中加快程序的开发速度的,
.jsp转换成-->serlet的.java,-->编译成.class,在JVM上执行,,,,要想运行jsp的程序,得完成这三个步骤,
.class的运行,在JVM上就能完成了
编译.java (这里是servlet)到.class, 由java编译器完成
.jsp转换成.java(这里是 servlet),由Jsper完成
JDK的功能:
提供了javac编译器, 能够 .java转变成.class,,不能把.jsp转换成.java,,,,
JDK虽然提供了javac,但是JDK本身无法按需自动的将.java转换成.class
我们就算使用基于CGI的servlet技术来开发.java,java页面任何改变了一点源程序,得重新编译,谁来监控源程序的改变?源程序发生改变后谁来手动的负责将.java转换成.class?谁来负责跟前端的web服务器进行交互? (基于CGI要跟web服务器进行交互的,谁来负责交互?我们需要一种特殊的机制,由此有一种专门的应用程序叫 Servlet Container )(Servlet容器),,说它是一个容器,实际它是包含了JDK,又包括了JDK本身所不具备的又能够让Servlet本身工身工作起来的额外的组件,
如下图,Servlet容器的框架下它是怎么工作的? 基于CGI技术,一定要接受前端web服务器的交互,所有前端有一个web应用程序,负责接受用户的请求,一旦发现用户的是一个CGI内容,开始转交给,执行运行一个Servlet程序,为了让Servlet能够长久的运行,不在每次运行时临时启动,得直接运行一个进程,(servlet程序直接在运行),负责通过CGI协议跟web服务器进行交互,把用户请求的内容接受进来之后,在本地的JVM上完成用户程序的执行,所以servlet容器负责接受CGI传递过来的请求,负责监控本地的.java程序是否发生了修改,,如果修改以后,转换成.class格式,而.class在JVM上执行(JDK包含了JVM???),,,它这里面必须要提供JDK,因为监控源程序发生改变了,还要调用编译器编译的,而编译器是JDK的组成部分,编译器的编译还要依赖于java的类库和额外的其它头文件(类似于C程序中的头文件等功能),
以上所说的只是servlet程序的执行,还不是jsp, 如果用到jsp技术,,,,如下图,,,,,jsp还需要额外的组件jsper,jsper负责监控jsp源程序的改变,并且随时按需要将其转换成.java,而.java程序还得交给servlet执行,,所以可以认为jsp技术就是在servlet之外添加了能够以嵌入式方式写动态的java页面,并且能够这个监控这个相应的页面什么时候改变,能够随时按需转换成.java页面的技术,一系列的技术规范,,,,,,,包含了jsper,包含了servlet,相关技术的这么一个框架,我们称为web container(web容器)
有时候我们不加区分地称呼 web container 和 servlet container ,
如下图,我们真正与用户请求的http请求交互,前端还得依赖于web服务器,我们把web服务器也整合进来,让它自己提供一个web服务器,用户请求的时候,直接跟web container进行交互,这样一来,这个容器的功能更强大了
现在很多的web container,都能够直接跟用户的请求进行交互的,意味着前端没有web服务器进行解码http请求,封装http响应,我们的web cotainer自带的组件(除了jsper之外,还能带一个额外的组件),也能直接跟客户端的用户交互的,,,,如下图,我们此时称为web container 的连接器,( 站在tomcat的角度来讲,称为 web container 的连接器 ),有连接器,我们可以直接跟用户交互,当然也可以把连接器用于跟前端web服务器程序进行交互,,,我们让连接器直接面对客户端,和前面使有web服务器代理有什么区别???????
如下图,我们装上lnmp之后, 直接面向用户,lnmp的性能要差得多,压力会很大,所以前面要装个nginx,所有用户的请求都与nginx建立连接,(所以维持用户的会话都在nginx上),当用户请求的内容nginx上没有(或者nginx不负责缓存),由nginx负责转发至后端
如下图,有了连接器功能以后,web container 可以直接面对用户,只不过如果连接器性能不强的话,那么压力会非常大,
如下图,前端放了web服务器(代理)以后,让web服务器承载用户会话的创建,释放等压力,最终跟连接器交互的是web服务器本身,(如果web服务器提供有缓存能力的话),那后端的应用程序服务器(web container)的压力会小很多,,,所以在这种情况下,它不是lnmp,就叫java的web容器(应用程序服务器),
我们无非就是在JVM的外层增加了其它一些组件,扩展了JVM功能,无论是web container也好,servlet container 也好,jdk也好,最终,它们都是运行在jvm虚拟机内的环境,无论你是一个web container,还是servlet container,,真正启动起来以后,在我们的操作系统上,它们都表现为一个JVM进程,如下图,在一个JVM进程内部,如果,你是一个web container,就有web container的功能,,,如果你是一个 servlet container,就有 servlet container 的功能,,,,否则就是只具有JVM自身的功能,,,这称为jvm instance (jvm实例),,,,,,,,,,如果我们很多用户同时发起请求,而且前端服务器也并发转进来了不止一个用户请求,,,比如通过连接器,直接跟我们的jsper进行交互,,,,,,,,,转发进来了大致有100个请求,而我们的容器,jvm实例只有一个,,,,,这100个请求,怎么能够并行执行?(php情况下,fast-cgi模式下,每一个请求,请求一个进程?????完成并发的),,,java(这里指JVM)怎么完成并发的?(jvm 实例的创建和撤销,比php的fast-cgi的进程?????要大得多),一般我们不会为每一个请求创建一个jvm实例的,,,,意味着在同一个jvm实例内部,它将启动多个线程,(java本身是完全支持多线程模型的),,,所以每一个请求进来,很可能就是一个线程,,,,,,,,,,,,这么多线程在同一个java的虚拟机内部执行,从根本上来讲,使得java(JVM)的内存空间可能会变得非常复杂,,,,如下图,简单描述一下,JVM虚拟机在运行起来的时候它的运行时数据区域,运行时数据区域本身所打开了的,所占据的内存空间划分,它运行起来,都是内存空间,这个内存空间非常复杂,它有许许多多的功能,java(JVM)为了管理内存区域功能,将它的内存区域划分为好几个区域,,,,
1)程序计数器区,因为java本身把自己模拟成一个虚拟机,在我们的cpu内部就有一个程序指针,这个指针,每一个进程是由指令加数据组成的,它每执行一条指令,就载入下一条再执行,然后继续载入下一条再执行,,当前指的哪一条,如果我们的进程需要切换出去的话,就要保存当前指的那一条的所有的东西,,,,,,,所以程序计数器区就是用来保存你的java代码中的程序执行到第几条指令了,因为java代码本身不是直接运行在cpu上的,是直接运行在JVM上的,所以JVM必须要模拟出来一个cpu的效果,,,,,所以每一个线程都需要一个计数器,,,,,而且每一个JVM实例在某一个时刻,它可能会调度每一个线程运行在每一颗cpu上(或多颗cpu上,也可能在多个cpu核心上????),反正是它必须为每一个执行的线程独立的在某个核心上维持一个程序计算器,,,,,,程序计数器区,每个线程都有自己独立的空间,,,,,
2)java虚拟机栈,(栈是什么?内存在一个进程内部分为堆和栈,栈通常用来保存本地变量的),,,,对于java虚拟机来讲,也是线程私有的,每一个线程得有自己的栈,应该有自己的变量,它通常用来存储局部变量(这个线程自己独有变量),用来存储方法出口,用来存储动态链接,指针, 用来存储操作数栈等等,所以都是线程私有的,,,,,,,java虚拟机栈,,每个线程都有自己独立的空间,,,,,,,,
3)方法区,(面向对象的编程时,有讲到方法,,,面向过程,只需要理解一个事情的解决过程就行了,比如为了写shell脚本,我们为了完成一个功能,直接按功能流,往下写就可以了,,,,面向对象,它要把整个程序处理的机制,像关系型数据库中的表一样,,把里面可能产生的任何一个机制,每一个操作的属性,集合,抽象成一个表,叫e-r关系图,,,,e-r对象, E称为实体entity,R称为关系Relation,,每一个实体由很多字段组成,每一个实体可以称为一张表,或者叫一个关系,,,,每一类实体组成一张表,表和表之间有关系,表内部(实体内部)属性之间也有关系,所以称为E-R关系,面向对象编程的时候,也是这样子的,面向对象的时候,我们要设计一个程序,首先看看这个程序中有多少个可以互相操作的对象,而后把这些对象给它抽象成类,,而每一类对象,它能够执行动作,我们称为操作,这些操作通常通过方法来完成,,,,比如汽车是一个类,卡车,小轿车,拖拉机,拖拉机执行的操作与小轿车执行的操作功能是不一样的,,,,把类做实例化的过程叫做对象,把车做成具体的车,,,,,每一个不同的对象一旦实例化出来之后,它能够完成的操作就确定下来了,,,坦克车的功能与小轿车的功能是不一样的,,,,所以每一类对象执行的操作叫做方法.),,,,方法区就是一类特定对象所能够执行的方法的集合,,,,,,,,,,方法区是共享的,因为同一类对象,它们的方法是一样的,只不过里面的数据不一样,所以执行的结果不一样,,,,,一辆劳斯莱斯跑10公里与一辆QQ跑100公里,输入的参数不一样,执行的结果所以不一样,,,同一类对象中的方法是一样的,可以为同一类进程所调用???????,,,,,,方法区是共享内存区,,,,
4)堆,与进程中的堆意义是一样的,对于jvm来讲,堆是最大的内存空间,堆里面放的是对象,我们把每一个类实例化以后,(对于面向对象的编程来讲,所有的文件都是类文件, 里面都是一些类,一执行起来,需要创建一堆对象,这些对象要执行操作,即执行方法,,执行方法的过程就是执行程序的过程,程序要进行计数器,每一个实例化的程序本身要保存自己的私有变量,,,,所以堆就是一个一个实例出来的对象)对于面向对象的编程来讲,对象是最多的,而且对象可能会非常的大,所以堆通常是最大的内存空间,在java虚拟机启动的时候,堆就直接被启动起来了,几乎所有的对象实例都在堆这儿存储,堆里面放了太多的对象,当某一个对象执行结束了,怎么办??(我们的进程,里面要执行很多指令,每一个指令运行结束了,因为指令本身要占据内存空间的,这些内存空间要释放的,),,,,我们这里的堆区,创建了很多对象,万一再创建对象,堆区里面存不下了,怎么办?,,,再比如方法区里面的方法也存不下了,怎么办?,,程序计数器区里面存不下的可能性很小,,java虚拟机栈也有可能存不下的,怎么办?,,可能会因为我们需要的内存空间太大,而导致存储无法完成,这就会溢出的,程序有可能会崩溃的,,,,所以为了避免溢出,要将那些经常不再用的废旧的数据????给它回收回来,给它清理出去,java是一种程序高级语言,java高级的重要特性表现在它能够自动完成内存回收的,,,,,,,,,,,,,,,,,堆区也是共享内存区
后面的hadoop是基于java的,
线程私有内存区:
程序计数器
java虚拟机栈
线程共享内存区:
方法区
堆 (java堆)
java可以实现自动内存回收,由GC( Garbage Collector)(垃圾回收器)来完成的,垃圾回收器始终监控堆区里面的对象,哪些对象很老了,走不动了,就从堆区里面清理掉了,,,,堆区里面的对象分类两类(一类新生代,一类是老年化),自动毙掉老年化对象,,,,,,因为堆里面对象不连续,所以清理掉老对象后,可能会产生碎片,所以垃圾回收器需要基于一定的算法来回收,(像linux内存中的buddy system???一样避免内存外碎片,swap allocate避免内存内碎片)(算法越好,越复杂,垃圾回收本身越占据资源)(有时程序跑得好好的,自动垃圾回收阶段性一运行,会突然跑得很慢)(如果碰巧访问量最大时,垃圾回收了,网站会很慢吧)
,,,,,如果堆空间分配得很大,溢出的可能性变小了,,,,,,Garbage Collector运行时有很多属性,专门用来调整堆的大小,方法区的大小等的最大值,最小值,以及垃圾回收器算法,(可能有多种算法,可以选择最合适的算法),,,,,,,
所以JVM程序启动的时候,可以传递许多参数进去的,
除了堆之外,另一个区域,叫本地方法栈,JVM中的方法有两类,一种叫java方法(java程序自身实现的方法,但是java上虚拟机,真正与系统打交道,需要系统调用,操作系统内核来完成,,,所以有些特定的功能需要系统调用来完成,,方法区里面的方法得转换成系统调用,这样子可能会慢一点,,,所以我们把java中的某些功能直接通过本地方法来实现,所以我们的java编程便糅合了本地操作系统编程,这样子我们完成跟硬件交互的时候能直接通过我们的CAPI????即system call直接跟操作系统打交道,执行性能有可能比java本身方法实现起来要快),一种叫本地方法
如下图,,,java可以调用java方法来实现,也可以调用外部的其它编程语言功能的方法来实现,调用外部的其它编程语言功能的方法叫做本地方法(本地方法栈),,,,,java自己的方法称为java方法(方法区),,,,,,,,,,,,,,本地方法栈与java虚拟机栈所实现的功能是一样的????是本地方法中的某些进程用到的时候来实现的,但是它跟我们的线程的关联性:并不一定是每一个线程所独有的了,,,,,,,我们最需要关心的是三个区: 方法区,java虚拟机栈,堆区
只要涉及到内存分配和回收,都有可能产生溢出的,
除此之外 java的运行时区域当中,在某些地方,比如在方法区里面,有一些子组件比较有名,叫本地常量区,或者叫运行时常量区,,,如下图,,,常量区是在方法区中保持常量的一段子区域,叫常量池,,,,,,,运行时的数据区域通常也会用到直接内存(类似于imap????)在jdk1.4当中,就引入了NIO(new input output)机制,它能够基于通道buffer的机制,直接跟我们的操作系统共享内存来互相操作的,免得内存数据复制的,,这是提高java性能的一种机制,,,这些只要是内存区域,都有可能导致内存溢出的,,所以我们必须要根据我们自己的内存需要,精心设计它们应该有多大,,,,万一溢出了,必须要监控,必须要随时进行处理
常量池有可能溢出,方法区可能溢出,本地方法区也可能溢出,,,,最有可能溢出的是堆区域,对象死了,对象结束了,也可能不是老年化,(人家已经运行结束了),所以要垃圾回收,,,,,
如下图,什么样的对象被认为已死呢?通常对象被某一个类创建出来之后,这个对象有个引用,(每一个对象,在java内部,都通常内部维护有一个叫做引用计数器,如果没人引用它了,就没必要存在了,引用计数器为0以后,意味着对象已死,可以回收了,但是并非每个时刻GC都会过来回收,,,每个对象死了以后,标记下,然后一批来进行GC垃圾回收)
GC垃圾回收时,有很多种算法,
1)标记(打上标记)清除(过一段时间一块来清除),,,,有个缺陷,谁死了清除谁,内存中会有大量碎片的,,,最常用,最简单
2)复制(每一个对象存储的时候,分两份区域,一份真正存储,另一份空闲着,用的进候往空闲处存数据?????,内存区域只有二分之一可用,,,,因为是通过复制的机制来进行创建的,所以回收后不会产生碎片,为什么????)(但是根据大公司的研究下来,IBM惠普等公司研究表明,类所创建的对象当中,98%的对象都会像浮游一样,生命周期只有短短的一瞬间,,,所以复制这种算法过于浪费空间,,,,,,,,,所以2%用复制算法,其它的用标记清除算法,一方面尽可能的避免垃圾碎片,也避免了区域浪费,),,,,,,所以现在几乎所有的商用的垃圾回收器,都是基于复制算法来实现的,不是1:1的空间来划分的,将那些新生代的朝生夕死的放在一个内存空间,标记-清除,而对那些需要长久使用的对象(通过监控来判断哪些是长久的)给它们实现复制,,,马哥讲,不必了解的太详细,
3)标记-整理算法,(复制数据算法对象存活率都很高,98%朝生夕死的,所以效率低),所以标记-整理算法是对复制算法的一种改进,,,,仍然采用标记清除,但后续不是直接回收清理的,每一个对象创建完给它标记,内存分为两段,第一段是创建,当不用的时候,把它移到另外一段,,第一段继续创建,,,,,,,,,,,,它对复制算法作了一定的改进,它也能尽可能的避免内存碎片的
如下图,无论哪一种算法,它们都是通过将我们的内存中所创建的对象分完类(新生代,老年化)来完成的,就算要进行清理,整理,也是对老年化对象处理的
上面所说的算法要用程序来实现吧
常见的垃圾回收器:
Serial:历史悠久,能完成新生代收集的,工作在新生代空间,对那些朝生夕死的(也都是新生代的)就能够回收的,(回收虽然我们归类为只回收那些老生代的,但是有些朝生夕死的,我们基于标记清除算法,也可以回收新生代的),,很古老,效率低,之所以叫Serial,是指一次它只能启动一个线程(进程?????),回收一个垃圾
ParNEW: (Parallel NEW )(并行的new算法)可以并行回收的,它能够实现多线程回收,能够调整Serail算法中本身不能提供的很多的算法细节调优等功能,,,所以ParNEW最多只是对Serial作了一些改进, 支持了多线程而已,但是在单cpu的环境中,它没有意义,没有办法使用多线程(想使用多线程,必须要多颗cpu)
Parallel Scavenge: 它也是能够针对新生代进行收集的,跟new差不多,但是它却能保证在实现垃圾回收的时候尽可能降低对其它正常执行进程的影响(降低它的停顿时间的),所以它的吞吐量比较高一点?????比如对于Serial,ParNEW,我们的虚拟机运行了100秒,垃圾回收可能占据了5秒,,而Parallel Scavenge的垃圾回收只占据了1秒,所以Parallel Scavenge会降低垃圾回收所占据的时间比例的.
Serial Old: 串行针对Old算法的实现,仍然是Serail算法,但是是针对老生代的,单线程的
Parallel Old: 并行针对Old算法的实现,多线程的
CMS: Concurrent Mark Sweep (并行标记清除器),它是使用标记清除算法的,在互联网场景当中,对某些场景下,每一个应用,都能够快速响应,所以它实现多线程,尽可能降低垃圾回收所占据的虚拟机运行的时间,因此它的主要目的也在于吞吐量优先,这是一款很优秀的回收器,,,,,,,,,,,,,,,,,,,,,,,,,,更先进的,Parallel Scavenge和Parallel Old揉合起来的,,,,
优点:能够实现并发收集,低停顿,
缺点:无法收集浮动垃圾(路边飘,容易扫走,河面上飘,是收集不了的)(浮动垃圾?如果某个线程正在运行着,而这个线程产生垃圾,这个线程会产生多个对象,只要一个线程处于运行过程当中,它所产生的垃圾就没法被收集,,,所以要想收集垃圾,我们会停顿的,但是我们为了保证垃圾回收的时候,所有的程序不会都停止,因此在某一时刻,假设JVM上一共有100个java线程,CPU有4个核心,在某一时刻,只运行了4个java线程,其余96个线程的垃圾都可以收集走了,,,这4个线程的垃圾我们就称为浮动垃圾,,,,CMS每一次运行是收集不了浮动垃圾的,那么就等待下一次,如果下一次时,这个垃圾不浮动了,那这个垃圾就可以收走了,,,,无论如何每一次都有可能有浮动垃圾的,所以仍然可能会导致堆溢出的)(所以这是CMS的一个缺陷,无法处理浮动垃圾,,,另外CMS基于标记-清除算法,因此有可能会产生碎片,)
G1: (Garbage first)(优先收集垃圾)好像尚未商用,比CMS有两个显著改进,第一,G1不会产生碎片,,,,第二,能够非常精确的控制停顿(用户可以定义停多长时间的),,所以使得用户对于垃圾回收的过程操作能力更强,,,,,,,,在jdk1.7当中,可能已经使用了,但是jdk1.7仍然不稳定,
一般多线程比单线程的要好很多,如果对cpu的资源比较敏感,或者尽可能的期望降低垃圾回收器的时间,我们要使用 Parallel Scavenge,或者 Parallel Old
我们在启动一个JVM的时候,想用哪个垃圾回收器,可以自己定义的,用老年化的收集器,还是新生代的收集器,用哪一种算法的收集器,根据我们的实际需要,可以进行调整,
由此我们发现JVM虚拟机运行过程当中,任何一个时刻,是需要看看堆是否溢出来,要随时监控java虚拟机的运行状况,
无论是垃圾回收器,还是垃圾回收算法,以及这些内存区域本身都是用在JVM中的,能够提供JVM运行的程序有多少个:
SUN:
JRE
JDK,是JRE的一个超集,包含了JRE中所不具备的某些开发功能,
Open:
OpenJDK
很多商业公司,像 IBM,惠普,Oracle都有自己的JDK(Weblogic????早期属于BEA公司,后来属于Oracle公司),,,,,,,,,,,,,所有的JDK都应该遵循java类文件所执行的基本要求,因此在一定程度上,它们是兼容的,,,,,,,,,,SUN的jdk,本来也是开源的,将来要用商用的话,要注意,看jdk中哪些规范当中的哪些内容是开源的,哪些是闭源的,,,,,
OpenJDK仍然是bug多多的,所以很少有公司在生产环境中使用,但是淘宝用的是OpenJDK,因为淘宝要对JDK本身作按需的改造,经过淘宝改进后的OpenJDK,修复了很多bug,提供了很多性能上的改进,而且已经开源出来了,可以到淘宝站点去看一看,
为了使用更成熟的技术,马哥建议使用sun的JDK,,只能到oracle的站点上去了,到谷歌上一搜就可以到oracle站点上去了,,,,,,,现在维护的有两个分支,一个是jdk1.6的,另一个是jdk1.7的,1.7目前来讲,虽然升级了好多次,但是很可能不太稳定,
jdk1.6
update几几几,,,,第几次升级版 update32,就是第32次升级版
jdk1.7
update几几几,,,,第几次升级版 update9,就是第9次升级版
jdk-1.6.32,,,,就是1.6版本的第32次升级版
马哥建议使用1.6的版本,,,如果程序员在开发的时候,使用了1.7的新功能的话,只能使用1.7的了,,,,,绝大多数的java新技术1.6都能够兼容,,,,,,1.6也不建议使用最新的,因为很多jdk经过测试发现,jdk-1.6.28挺稳定的,但是jdk-1.6.32不一定????????,,,,,,,jdk-1.6.32挺稳定的,但是jdk-1.6.28不一定??????,,,,,,,,,,,,,,,,,,,,,很多官方经过测试的,比如在hadoop上,(至少hadoop跟jdk结合的时候,因为hadoop本身也是用java开发的,,,它就特别建议你使用某个特定的版本,, 而非最新的版本,也非次版本中比较新的版本,)
安装jdk,三种方式
1)rpm,
2)通用二进制格式(解压后就能用的),但是一般来讲,不是让你解压后用,而是让你安装的,它是.bin格式的安装程序,通常在所有平台上都可以使用的
3)源码,有点难度,不建议使用,而且源码编译一般来讲,只能使用openjdk去进行编译(sun的jdk好像是不提供源码编译的,应该有提供吧,但马哥没试过)
在红帽6上安装jdk试试
红帽6上本身自带有rpm格式的java环境,可以使用系统自带的,也可以使用官方提供的rpm包,(跟mysql类似),,系统自带的与官方提供的在某些组织上不尽相同,
[root@master ~]# yum list all | grep java
java-1.6.0-openjdk.i686 1:1.6.0.41-1.13.13.1.el6_8 @anaconda-RedHatEnterpriseLinux-201805250237.i386/6.10 #用的openjdk
java-1.7.0-openjdk.i686 1:1.7.0.181-2.6.14.10.el6 @anaconda-RedHatEnterpriseLinux-201805250237.i386/6.10
libvirt-java.noarch 0.4.9-1.el6 @Base
libvirt-java-devel.noarch 0.4.9-1.el6 @Base
tzdata-java.noarch 2018e-3.el6 @anaconda-RedHatEnterpriseLinux-201805250237.i386/6.10
ant-javamail.i686 1.7.1-15.el6 Base
eclipse-mylyn-java.i686 3.4.2-9.el6 Base
gcc-java.i686 4.4.7-23.el6 Base
java-1.5.0-gcj.i686 1.5.0.0-29.1.el6 Base
java-1.5.0-gcj-devel.i686 1.5.0.0-29.1.el6 Base
java-1.6.0-openjdk-devel.i686 1:1.6.0.41-1.13.13.1.el6_8 Base #用的openjdk
java-1.6.0-openjdk-javadoc.i686 1:1.6.0.41-1.13.13.1.el6_8 Base
java-1.7.0-openjdk-devel.i686 1:1.7.0.181-2.6.14.10.el6 Base
java-1.8.0-openjdk.i686 1:1.8.0.171-8.b10.el6_9 Base
java-1.8.0-openjdk-devel.i686 1:1.8.0.171-8.b10.el6_9 Base
java-1.8.0-openjdk-headless.i686 1:1.8.0.171-8.b10.el6_9 Base
java_cup.i686 1:0.10k-5.el6 Base
javassist.noarch 3.9.0-6.el6 Base
lpg-java-compat.noarch 1.1.0-4.1.el6 Base
mysql-connector-java.noarch 1:5.1.17-6.el6 Base
pki-java-tools.noarch 9.0.3-53.el6 Base
subversion-javahl.i686 1.6.11-15.el6_7 Base
[root@master ~]#
jdk-6u21-linux-i586-rpm.bin 这个版本稍微稳定些, 6u21表示6的第21次升级, rpm.bin表示先安装下,会自动给我生成rpm包,而且它自己去安装rpm包,,,,所以事实上它是rpm格式的,也是二进制格式
这里7版本只有rpm 没有rpm.bin,到7以后组织机制变了,但是仍然是rpm格式的,
记住安装时要与操作版本相匹配,看是32位还是64位的
https://sourceforge.net/projects/crawlzilla/files/other/
https://sourceforge.net/projects/crawlzilla/files/other/jdk-6u21-linux-i586-rpm.bin/download
[root@master ~]# wget https://sourceforge.net/projects/crawlzilla/files/other/jdk-6u21-linux-i586-rpm.bin/download -O jdk-6u21-linux-i586-rpm.bin
[root@master ~]# ls
\ memcache-2.2.6.tgz
anaconda-ks.cfg memcached-1.4.5
download memcached-1.4.5.tar.gz
haproxy-1.4.22-3.el6.i686.rpm mysql-5.6.10-linux-glibc2.5-i686.tar.gz
install.log mysql-5.6.10-linux-glibc2.5-i686.tar.gz.1
install.log.syslog mysql-5.6.10-linux-glibc2.5-i686.tar.gz.2
iptables.20210319 nginx-1.4.7
jdk-6u21-linux-i586-rpm.bin nginx-1.4.7.tar.gz
libevent-2.0.20-stable package.xml
libevent-2.0.20-stable.tar.gz php-5.4.13
memadmin-master.zip php-5.4.13.tar.bz2
memcache-2.2.6 test.txt
[root@master ~]#
[root@master ~]# chmod +x jdk-6u21-linux-i586-rpm.bin #给执行权限
[root@master ~]#
[root@master ~]#
[root@master ~]# ./jdk-6u21-linux-i586-rpm.bin #直接运行 它自动解压一堆的rpm包,放在当前目录下,而且自动给你装上去,装完以后展开jar文件(jar与tar是一个意思,是java的压缩归档文件),可以把java的类压缩归档以后进行存储,可以保存至某一个目录下,节约空间的,
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u21-linux-i586.rpm
inflating: sun-javadb-common-10.5.3-0.2.i386.rpm
inflating: sun-javadb-core-10.5.3-0.2.i386.rpm
inflating: sun-javadb-client-10.5.3-0.2.i386.rpm
inflating: sun-javadb-demo-10.5.3-0.2.i386.rpm
inflating: sun-javadb-docs-10.5.3-0.2.i386.rpm
inflating: sun-javadb-javadoc-10.5.3-0.2.i386.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files...
rt.jar...
jsse.jar...
charsets.jar...
tools.jar...
localedata.jar...
plugin.jar...
javaws.jar...
deploy.jar...
Installing JavaDB
Preparing... ########################################### [100%]
1:sun-javadb-common ########################################### [ 17%]
2:sun-javadb-core ########################################### [ 33%]
3:sun-javadb-client ########################################### [ 50%]
4:sun-javadb-demo ########################################### [ 67%]
5:sun-javadb-docs ########################################### [ 83%]
6:sun-javadb-javadoc ########################################### [100%]
Java(TM) SE Development Kit 6 successfully installed.
Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Sun products, services and training
* Access to early releases and documentation
Product and system data will be collected. If your configuration
supports a browser, the Sun Product Registration form for
the JDK will be presented. If you do not register, none of
this information will be saved. You may also register your
JDK later by opening the register.html file (located in
the JDK installation directory) in a browser.
For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html
Press Enter to continue.....
Done.
[root@master ~]#
[root@master ~]# ls #当前目录下解压出来一堆的rpm包
\ mysql-5.6.10-linux-glibc2.5-i686.tar.gz
anaconda-ks.cfg mysql-5.6.10-linux-glibc2.5-i686.tar.gz.1
download mysql-5.6.10-linux-glibc2.5-i686.tar.gz.2
haproxy-1.4.22-3.el6.i686.rpm nginx-1.4.7
install.log nginx-1.4.7.tar.gz
install.log.syslog package.xml
iptables.20210319 php-5.4.13
jdk-6u21-linux-i586.rpm php-5.4.13.tar.bz2
jdk-6u21-linux-i586-rpm.bin sun-javadb-client-10.5.3-0.2.i386.rpm
libevent-2.0.20-stable sun-javadb-common-10.5.3-0.2.i386.rpm
libevent-2.0.20-stable.tar.gz sun-javadb-core-10.5.3-0.2.i386.rpm
memadmin-master.zip sun-javadb-demo-10.5.3-0.2.i386.rpm
memcache-2.2.6 sun-javadb-docs-10.5.3-0.2.i386.rpm
memcache-2.2.6.tgz sun-javadb-javadoc-10.5.3-0.2.i386.rpm
memcached-1.4.5 test.txt
memcached-1.4.5.tar.gz
[root@master ~]#
[root@master ~]# ls /usr/java #默认安装路径
default jdk1.6.0_21 latest
[root@master ~]#
[root@master ~]# ls -la /usr/java #latest软链接,通向指向版本最高的
总用量 12
drwxr-xr-x. 3 root root 4096 6月 23 16:48 .
drwxr-xr-x. 14 root root 4096 6月 23 16:48 ..
lrwxrwxrwx. 1 root root 16 6月 23 16:48 default -> /usr/java/latest
drwxr-xr-x. 9 root root 4096 6月 23 16:48 jdk1.6.0_21
lrwxrwxrwx. 1 root root 21 6月 23 16:48 latest -> /usr/java/jdk1.6.0_21
[root@master ~]#
[root@master jdk1.6.0_21]# cd /usr/java/jdk1.6.0_21/
[root@master jdk1.6.0_21]# ls bin/ #最重要的是java(启动虚拟机靠它)和javac(完成编译靠它)命令
appletviewer java jcontrol(图形化的监控控制台) jstack(监控工具?) policytool unpack200
apt(是另外一种非常重要的打包工具) javac (编译器) jdb(调试工具??) jstat(监控工具?) rmic wsgen
ControlPanel javadoc(java文档生成工具 ) jhat jstatd rmid wsimport
extcheck javah jinfo jvisualvm rmiregistry xjc
HtmlConverter javap jmap(监控工具?) keytool schemagen
idlj java-rmi.cgi jps native2ascii serialver
jar(打包工具) javaws jrunscript orbd servertool
jarsigner jconsole jsadebugd pack200 tnameserv
[root@master jdk1.6.0_21]#
[root@master jdk1.6.0_21]# pwd
/usr/java/jdk1.6.0_21
[root@master jdk1.6.0_21]# ls include/ #头文件
classfile_constants.h jawt.h jdwpTransport.h jni.h jvmti.h linux
[root@master jdk1.6.0_21]#
[root@master jdk1.6.0_21]# ls lib/ #库文件,库文件以.jar结尾(压缩存放的,里面可能有很多的函数)
ct.sym htmlconverter.jar jconsole.jar orb.idl tools.jar
dt.jar ir.idl jexec sa-jdi.jar visualvm
[root@master jdk1.6.0_21]#
[root@master jdk1.6.0_21]# ls man/ #帮助
ja ja_JP.eucJP man1
[root@master jdk1.6.0_21]#
配置java 的环境变量
java自身所有的运行环境,它自己都得知道,要靠一个环境变量java_home来定义
[root@master jdk1.6.0_21]# vim /etc/profile.d/java.sh
export JAVA_HOME=/usr/java/jdk1.6.0_21
export PATH=$PATH:$JAVA_HOME/bin
[root@master jdk1.6.0_21]# . /etc/profile.d/java.sh #读一下它,把它加入环境变量了
[root@master jdk1.6.0_21]#
[root@master jdk1.6.0_21]# java -version
java version "1.7.0_181" #版本不对啊,原来有1.7啊
OpenJDK Runtime Environment (rhel-2.6.14.10.el6-i386 u181-b00)
OpenJDK Server VM (build 24.181-b00, mixed mode)
[root@master jdk1.6.0_21]#
[root@master jdk1.6.0_21]# which java
/usr/bin/java #原1.7在这里
[root@master jdk1.6.0_21]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql/bin:/root/bin:/usr/java/jdk1.6.0_21/bin #新安装的1.6是/usr/java/jdk1.6.0_21/bin/java,咋办?
[root@master jdk1.6.0_21]#
[root@master jdk1.6.0_21]# mv /usr/bin/java /usr/bin/java1.7
[root@master jdk1.6.0_21]# source /etc/profile #重读环境变量文件
[root@master jdk1.6.0_21]# java -version #现在变成1.6的了
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode)
[root@master jdk1.6.0_21]#
实现启动java虚拟机JVM,无非就是运行一个java程序,在bin/java下,
[root@master jdk1.6.0_21]# java --help
Unrecognized option: --help
Could not create the Java virtual machine. #当作虚拟机,当作类文件,要执行的
[root@master jdk1.6.0_21]#
启动虚拟机,需要的配置参数
# java -XX:+PrintFlagsFinal #来配置虚拟机参数
很多时候都是使用-XX来配置参数的
java配置参数:
-XX:+<option>: 开启此参数指定的功能;布尔型
-XX:-<option>:关闭功能;布尔型
-XX:<option>=<value>:给option指定的选项赋值; 非布尔型
java -XX:+PrintFlagsFinal 显示其所支持的所有的参数及默认值
-D<name>=<value>: set a system property #设置一个系统属性值,偶尔用到
[root@master ~]# java -XX:+PrintFlagsFinal #这些参数大多数为布尔型的, 很多是调整垃圾收集器,调整内存分配与回收等参数,内存分配有多大,回收有多大,使用什么垃圾回收算法,垃圾回收算法的各种参数怎么定义,DTrace开启追踪功能等
[Global flags]
uintx AdaptivePermSizeWeight = 20 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product}
uintx AdaptiveSizePolicyOutputInterval = 0 {product}
uintx AdaptiveSizePolicyWeight = 10 {product}
uintx AdaptiveSizeThroughPutPolicy = 0 {product}
uintx AdaptiveTimeWeight = 25 {product}
bool AdjustConcurrency = false {product}
bool AggressiveOpts = false {product}
intx AliasLevel = 3 {product}
intx AllocatePrefetchDistance = -1 {product}
intx AllocatePrefetchInstr = 0 {product}
intx AllocatePrefetchLines = 1 {product}
intx AllocatePrefetchStepSize = 16 {product}
intx AllocatePrefetchStyle = 1 {product}
bool AllowJNIEnvProxy = false {product}
bool AllowParallelDefineClass = false {product}
bool AllowUserSignalHandlers = false {product}
bool AlwaysActAsServerClassMachine = false {product}
bool AlwaysCompileLoopMethods = false {product}
intx AlwaysInflate = 0 {product}
bool AlwaysLockClassLoader = false {product}
bool AlwaysPreTouch = false {product}
bool AlwaysRestoreFPU = false {product}
bool AlwaysTenure = false {product}
bool AnonymousClasses = false {product}
bool AssertOnSuspendWaitFailure = false {product}
intx Atomics = 0 {product}
intx AutoBoxCacheMax = 128 {C2 product}
uintx AutoGCSelectPauseMillis = 5000 {product}
intx BCEATraceLevel = 0 {product}
intx BackEdgeThreshold = 100000 {pd product}
bool BackgroundCompilation = true {pd product}
uintx BaseFootPrintEstimate = 268435456 {product}
intx BiasedLockingBulkRebiasThreshold = 20 {product}
intx BiasedLockingBulkRevokeThreshold = 40 {product}
intx BiasedLockingDecayTime = 25000 {product}
intx BiasedLockingStartupDelay = 4000 {product}
bool BindGCTaskThreadsToCPUs = false {product}
bool BlockLayoutByFrequency = true {C2 product}
intx BlockLayoutMinDiamondPercentage = 20 {C2 product}
bool BlockLayoutRotateLoops = true {C2 product}
bool BlockOffsetArrayUseUnallocatedBlock = false {product}
bool BranchOnRegister = false {C2 product}
bool BytecodeVerificationLocal = false {product}
bool BytecodeVerificationRemote = true {product}
intx CICompilerCount = 2 {product}
bool CICompilerCountPerCPU = false {product}
bool CITime = false {product}
bool CMSAbortSemantics = false {product}
uintx CMSAbortablePrecleanMinWorkPerIteration = 100 {product}
intx CMSAbortablePrecleanWaitMillis = 100 {product}
uintx CMSBitMapYieldQuantum = 10485760 {product}
uintx CMSBootstrapOccupancy = 50 {product}
bool CMSClassUnloadingEnabled = false {product}
uintx CMSClassUnloadingMaxInterval = 0 {product}
bool CMSCleanOnEnter = true {product}
bool CMSCompactWhenClearAllSoftRefs = true {product}
uintx CMSConcMarkMultiple = 32 {product}
bool CMSConcurrentMTEnabled = true {product}
uintx CMSCoordinatorYieldSleepCount = 10 {product}
bool CMSDumpAtPromotionFailure = false {product}
uintx CMSExpAvgFactor = 50 {product}
bool CMSExtrapolateSweep = false {product}
uintx CMSFullGCsBeforeCompaction = 0 {product}
uintx CMSIncrementalDutyCycle = 10 {product}
uintx CMSIncrementalDutyCycleMin = 0 {product}
bool CMSIncrementalMode = false {product}
uintx CMSIncrementalOffset = 0 {product}
bool CMSIncrementalPacing = true {product}
uintx CMSIncrementalSafetyFactor = 10 {product}
uintx CMSIndexedFreeListReplenish = 4 {product}
intx CMSInitiatingOccupancyFraction = -1 {product}
intx CMSInitiatingPermOccupancyFraction = -1 {product}
intx CMSIsTooFullPercentage = 98 {product}
double CMSLargeCoalSurplusPercent = {product}
double CMSLargeSplitSurplusPercent = {product}
bool CMSLoopWarn = false {product}
uintx CMSMaxAbortablePrecleanLoops = 0 {product}
intx CMSMaxAbortablePrecleanTime = 5000 {product}
uintx CMSOldPLABMax = 1024 {product}
uintx CMSOldPLABMin = 16 {product}
uintx CMSOldPLABNumRefills = 4 {product}
uintx CMSOldPLABReactivityCeiling = 10 {product}
uintx CMSOldPLABReactivityFactor = 2 {product}
bool CMSOldPLABResizeQuicker = false {product}
uintx CMSOldPLABToleranceFactor = 4 {product}
bool CMSPLABRecordAlways = true {product}
uintx CMSParPromoteBlocksToClaim = 16 {product}
bool CMSParallelRemarkEnabled = true {product}
bool CMSParallelSurvivorRemarkEnabled = true {product}
bool CMSPermGenPrecleaningEnabled = true {product}
uintx CMSPrecleanDenominator = 3 {product}
uintx CMSPrecleanIter = 3 {product}
uintx CMSPrecleanNumerator = 2 {product}
bool CMSPrecleanRefLists1 = true {product}
bool CMSPrecleanRefLists2 = false {product}
bool CMSPrecleanSurvivors1 = false {product}
bool CMSPrecleanSurvivors2 = true {product}
uintx CMSPrecleanThreshold = 1000 {product}
bool CMSPrecleaningEnabled = true {product}
bool CMSPrintChunksInDump = false {product}
bool CMSPrintObjectsInDump = false {product}
uintx CMSRemarkVerifyVariant = 1 {product}
bool CMSReplenishIntermediate = true {product}
uintx CMSRescanMultiple = 32 {product}
uintx CMSRevisitStackSize = 1048576 {product}
uintx CMSSamplingGrain = 16384 {product}
bool CMSScavengeBeforeRemark = false {product}
uintx CMSScheduleRemarkEdenPenetration = 50 {product}
uintx CMSScheduleRemarkEdenSizeThreshold = 2097152 {product}
uintx CMSScheduleRemarkSamplingRatio = 5 {product}
double CMSSmallCoalSurplusPercent = {product}
double CMSSmallSplitSurplusPercent = {product}
bool CMSSplitIndexedFreeListBlocks = true {product}
intx CMSTriggerPermRatio = 80 {product}
intx CMSTriggerRatio = 80 {product}
bool CMSUseOldDefaults = false {product}
intx CMSWaitDuration = 2000 {product}
uintx CMSWorkQueueDrainThreshold = 10 {product}
bool CMSYield = true {product}
uintx CMSYieldSleepCount = 0 {product}
intx CMSYoungGenPerWorker = 16777216 {product}
uintx CMS_FLSPadding = 1 {product}
uintx CMS_FLSWeight = 75 {product}
uintx CMS_SweepPadding = 1 {product}
uintx CMS_SweepTimerThresholdMillis = 10 {product}
uintx CMS_SweepWeight = 75 {product}
bool CheckJNICalls = false {product}
bool ClassUnloading = true {product}
intx ClearFPUAtPark = 0 {product}
bool ClipInlining = true {product}
uintx CodeCacheExpansionSize = 32768 {pd product}
uintx CodeCacheFlushingMinimumFreeSpace = 1536000 {product}
uintx CodeCacheMinimumFreeSpace = 512000 {product}
bool CollectGen0First = false {product}
bool CompactFields = true {product}
intx CompilationPolicyChoice = 0 {product}
intx CompilationRepeat = 0 {C1 product}
ccstrlist CompileCommand = {product}
ccstr CompileCommandFile = {product}
ccstrlist CompileOnly = {product}
intx CompileThreshold = 10000 {pd product}
bool CompilerThreadHintNoPreempt = true {product}
intx CompilerThreadPriority = -1 {product}
intx CompilerThreadStackSize = 0 {pd product}
uintx ConcGCThreads = 0 {product}
intx ConditionalMoveLimit = 3 {C2 pd product}
bool ConvertSleepToYield = true {pd product}
bool ConvertYieldToSleep = false {product}
bool DTraceAllocProbes = false {product}
bool DTraceMethodProbes = false {product}
bool DTraceMonitorProbes = false {product}
uintx DefaultMaxRAMFraction = 4 {product}
intx DefaultThreadPriority = -1 {product}
intx DeferPollingPageLoopCount = -1 {product}
intx DeferThrSuspendLoopCount = 4000 {product}
bool DeoptimizeRandom = false {product}
bool DisableAttachMechanism = false {product}
bool DisableExplicitGC = false {product}
bool DisplayVMOutputToStderr = false {product}
bool DisplayVMOutputToStdout = false {product}
bool DoEscapeAnalysis = false {C2 product}
intx DominatorSearchLimit = 1000 {C2 diagnostic}
bool DontCompileHugeMethods = true {product}
bool DontYieldALot = false {pd product}
bool DumpSharedSpaces = false {product}
bool EagerXrunInit = false {product}
intx EliminateAllocationArraySizeLimit = 64 {C2 product}
bool EliminateAllocations = true {C2 product}
bool EliminateAutoBox = false {C2 diagnostic}
bool EliminateLocks = true {C2 product}
intx EmitSync = 0 {product}
uintx ErgoHeapSizeLimit = 0 {product}
ccstr ErrorFile = {product}
bool EstimateArgEscape = true {product}
intx EventLogLength = 2000 {product}
bool ExplicitGCInvokesConcurrent = false {product}
bool ExplicitGCInvokesConcurrentAndUnloadsClasses = false {product}
bool ExtendedDTraceProbes = false {product}
bool FLSAlwaysCoalesceLarge = false {product}
uintx FLSCoalescePolicy = 2 {product}
double FLSLargestBlockCoalesceProximity = {product}
bool FailOverToOldVerifier = true {product}
bool FastTLABRefill = true {product}
intx FenceInstruction = 0 {product}
intx FieldsAllocationStyle = 1 {product}
bool FilterSpuriousWakeups = true {product}
bool ForceFullGCJVMTIEpilogues = false {product}
bool ForceNUMA = false {product}
bool ForceSharedSpaces = false {product}
bool ForceTimeHighResolution = false {product}
intx FreqInlineSize = 325 {pd product}
intx G1ConcRefinementGreenZone = 0 {product}
intx G1ConcRefinementRedZone = 0 {product}
intx G1ConcRefinementServiceIntervalMillis = 300 {product}
uintx G1ConcRefinementThreads = 0 {product}
intx G1ConcRefinementThresholdStep = 0 {product}
intx G1ConcRefinementYellowZone = 0 {product}
intx G1ConfidencePercent = 50 {product}
uintx G1HeapRegionSize = 0 {product}
intx G1MarkRegionStackSize = 1048576 {product}
intx G1RSetRegionEntries = 0 {product}
uintx G1RSetScanBlockSize = 64 {product}
intx G1RSetSparseRegionEntries = 0 {product}
intx G1RSetUpdatingPauseTimePercent = 10 {product}
intx G1ReservePercent = 10 {product}
intx G1SATBBufferSize = 1024 {product}
intx G1UpdateBufferSize = 256 {product}
bool G1UseAdaptiveConcRefinement = true {product}
bool G1UseFixedWindowMMUTracker = false {product}
uintx GCDrainStackTargetSize = 64 {product}
uintx GCHeapFreeLimit = 2 {product}
bool GCOverheadReporting = false {product}
intx GCOverheadReportingPeriodMS = 100 {product}
intx GCPauseIntervalMillis = 500 {product}
uintx GCTaskTimeStampEntries = 200 {product}
uintx GCTimeLimit = 98 {product}
uintx GCTimeRatio = 99 {product}
ccstr HPILibPath = {product}
bool HandlePromotionFailure = true {product}
uintx HeapBaseMinAddress = 2147483648 {pd product}
bool HeapDumpAfterFullGC = false {manageable}
bool HeapDumpBeforeFullGC = false {manageable}
bool HeapDumpOnOutOfMemoryError = false {manageable}
ccstr HeapDumpPath = {manageable}
uintx HeapFirstMaximumCompactionCount = 3 {product}
uintx HeapMaximumCompactionInterval = 20 {product}
bool IgnoreUnrecognizedVMOptions = false {product}
uintx InitialCodeCacheSize = 2359296 {pd product}
uintx InitialHeapSize := 31007040 {product}
uintx InitialRAMFraction = 64 {product}
uintx InitialSurvivorRatio = 8 {product}
intx InitialTenuringThreshold = 7 {product}
uintx InitiatingHeapOccupancyPercent = 45 {product}
bool Inline = true {product}
intx InlineSmallCode = 1000 {pd product}
bool InsertMemBarAfterArraycopy = true {C2 product}
intx InteriorEntryAlignment = 4 {C2 pd product}
intx InterpreterProfilePercentage = 33 {product}
bool JNIDetachReleasesMonitors = true {product}
bool JavaMonitorsInStackTrace = true {product}
intx JavaPriority10_To_OSPriority = -1 {product}
intx JavaPriority1_To_OSPriority = -1 {product}
intx JavaPriority2_To_OSPriority = -1 {product}
intx JavaPriority3_To_OSPriority = -1 {product}
intx JavaPriority4_To_OSPriority = -1 {product}
intx JavaPriority5_To_OSPriority = -1 {product}
intx JavaPriority6_To_OSPriority = -1 {product}
intx JavaPriority7_To_OSPriority = -1 {product}
intx JavaPriority8_To_OSPriority = -1 {product}
intx JavaPriority9_To_OSPriority = -1 {product}
bool LIRFillDelaySlots = false {C1 pd product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx LargePageSizeInBytes = 0 {product}
bool LazyBootClassLoader = true {product}
intx LoopOptsCount = 43 {C2 product}
intx LoopUnrollLimit = 50 {C2 pd product}
intx LoopUnrollMin = 4 {C2 product}
bool LoopUnswitching = true {C2 product}
bool ManagementServer = false {product}
uintx MarkStackSize = 32768 {product}
uintx MarkStackSizeMax = 4194304 {product}
intx MarkSweepAlwaysCompactCount = 4 {product}
uintx MarkSweepDeadRatio = 5 {product}
intx MaxBCEAEstimateLevel = 5 {product}
intx MaxBCEAEstimateSize = 150 {product}
intx MaxDirectMemorySize = -1 {product}
bool MaxFDLimit = true {product}
uintx MaxGCMinorPauseMillis = 4294967295 {product}
uintx MaxGCPauseMillis = 4294967295 {product}
uintx MaxHeapFreeRatio = 70 {product}
uintx MaxHeapSize := 496112640 {product}
intx MaxInlineLevel = 9 {product}
intx MaxInlineSize = 35 {product}
intx MaxJavaStackTraceDepth = 1024 {product}
intx MaxJumpTableSize = 65000 {C2 product}
intx MaxJumpTableSparseness = 5 {C2 product}
intx MaxLabelRootDepth = 1100 {C2 product}
uintx MaxLiveObjectEvacuationRatio = 100 {product}
intx MaxLoopPad = 15 {C2 product}
uintx MaxNewSize = 4294967295 {product}
intx MaxNodeLimit = 65000 {C2 product}
uintx MaxPermHeapExpansion = 4194304 {product}
uintx MaxPermSize = 67108864 {pd product}
uint64_t MaxRAM = 0 {pd product}
uintx MaxRAMFraction = 4 {product}
intx MaxRecursiveInlineLevel = 1 {product}
intx MaxTenuringThreshold = 15 {product}
intx MaxTrivialSize = 6 {product}
bool MethodFlushing = true {product}
intx MinCodeCacheFlushingInterval = 30 {product}
uintx MinHeapDeltaBytes = 131072 {product}
uintx MinHeapFreeRatio = 40 {product}
intx MinInliningThreshold = 250 {product}
intx MinJumpTableSize = 18 {C2 product}
uintx MinPermHeapExpansion = 262144 {product}
uintx MinRAMFraction = 2 {product}
uintx MinSurvivorRatio = 3 {product}
uintx MinTLABSize = 2048 {product}
intx MonitorBound = 0 {product}
bool MonitorInUseLists = false {product}
intx MultiArrayExpandLimit = 6 {C2 product}
bool MustCallLoadClassInternal = false {product}
intx NUMAChunkResizeWeight = 20 {product}
intx NUMAPageScanRate = 256 {product}
intx NUMASpaceResizeRate = 1073741824 {product}
bool NUMAStats = false {product}
intx NativeMonitorFlags = 0 {product}
intx NativeMonitorSpinLimit = 20 {product}
intx NativeMonitorTimeout = -1 {product}
bool NeedsDeoptSuspend = false {pd product}
bool NeverActAsServerClassMachine = false {pd product}
bool NeverTenure = false {product}
intx NewRatio = 2 {product}
uintx NewSize = 1048576 {product}
uintx NewSizeThreadIncrease = 4096 {pd product}
intx NmethodSweepFraction = 4 {product}
intx NodeLimitFudgeFactor = 1000 {C2 product}
intx NumberOfLoopInstrToAlign = 4 {C2 product}
uintx OldPLABSize = 1024 {product}
uintx OldPLABWeight = 50 {product}
uintx OldSize = 4194304 {product}
bool OmitStackTraceInFastThrow = true {product}
ccstrlist OnError = {product}
ccstrlist OnOutOfMemoryError = {product}
intx OnStackReplacePercentage = 140 {pd product}
bool OptimizeStringConcat = false {C2 product}
bool OptoBundling = false {C2 pd product}
intx OptoLoopAlignment = 16 {C2 pd product}
bool OptoScheduling = false {C2 pd product}
uintx PLABWeight = 75 {product}
bool PSChunkLargeArrays = true {product}
intx ParGCArrayScanChunk = 50 {product}
uintx ParGCDesiredObjsFromOverflowList = 20 {product}
bool ParGCTrimOverflow = true {product}
bool ParGCUseLocalOverflow = false {product}
intx ParallelGCBufferWastePct = 10 {product}
bool ParallelGCRetainPLAB = true {product}
uintx ParallelGCThreads := 8 {product}
bool ParallelGCVerbose = false {product}
uintx ParallelOldDeadWoodLimiterMean = 50 {product}
uintx ParallelOldDeadWoodLimiterStdDev = 80 {product}
bool ParallelRefProcBalancingEnabled = true {product}
bool ParallelRefProcEnabled = false {product}
bool PartialPeelAtUnsignedTests = true {C2 product}
bool PartialPeelLoop = true {C2 product}
intx PartialPeelNewPhiDelta = 0 {C2 product}
uintx PausePadding = 1 {product}
intx PerBytecodeRecompilationCutoff = 200 {product}
intx PerBytecodeTrapLimit = 4 {product}
intx PerMethodRecompilationCutoff = 400 {product}
intx PerMethodTrapLimit = 100 {product}
bool PerfAllowAtExitRegistration = false {product}
bool PerfBypassFileSystemCheck = false {product}
intx PerfDataMemorySize = 32768 {product}
intx PerfDataSamplingInterval = 50 {product}
ccstr PerfDataSaveFile = {product}
bool PerfDataSaveToFile = false {product}
bool PerfDisableSharedMem = false {product}
intx PerfMaxStringConstLength = 1024 {product}
uintx PermGenPadding = 3 {product}
uintx PermMarkSweepDeadRatio = 20 {product}
uintx PermSize = 16777216 {pd product}
bool PostSpinYield = true {product}
intx PreBlockSpin = 10 {product}
intx PreInflateSpin = 10 {pd product}
bool PreSpinYield = false {product}
bool PreferInterpreterNativeStubs = false {pd product}
intx PrefetchCopyIntervalInBytes = -1 {product}
intx PrefetchFieldsAhead = -1 {product}
intx PrefetchScanIntervalInBytes = -1 {product}
bool PreserveAllAnnotations = false {product}
uintx PreserveMarkStackSize = 1024 {product}
uintx PretenureSizeThreshold = 0 {product}
bool PrintAdaptiveSizePolicy = false {product}
bool PrintCMSInitiationStatistics = false {product}
intx PrintCMSStatistics = 0 {product}
bool PrintClassHistogram = false {manageable}
bool PrintClassHistogramAfterFullGC = false {manageable}
bool PrintClassHistogramBeforeFullGC = false {manageable}
bool PrintCommandLineFlags = false {product}
bool PrintCompilation = false {product}
bool PrintConcurrentLocks = false {manageable}
intx PrintFLSCensus = 0 {product}
intx PrintFLSStatistics = 0 {product}
bool PrintFlagsFinal := true {product}
bool PrintFlagsInitial = false {product}
bool PrintGC = false {manageable}
bool PrintGCApplicationConcurrentTime = false {product}
bool PrintGCApplicationStoppedTime = false {product}
bool PrintGCDateStamps = false {manageable}
bool PrintGCDetails = false {manageable}
bool PrintGCTaskTimeStamps = false {product}
bool PrintGCTimeStamps = false {manageable}
bool PrintHeapAtGC = false {product rw}
bool PrintHeapAtGCExtended = false {product rw}
bool PrintHeapAtSIGBREAK = true {product}
bool PrintJNIGCStalls = false {product}
bool PrintJNIResolving = false {product}
bool PrintOldPLAB = false {product}
bool PrintPLAB = false {product}
bool PrintParallelOldGCPhaseTimes = false {product}
bool PrintPreciseBiasedLockingStatistics = false {C2 diagnostic}
bool PrintPromotionFailure = false {product}
bool PrintReferenceGC = false {product}
bool PrintRevisitStats = false {product}
bool PrintSafepointStatistics = false {product}
intx PrintSafepointStatisticsCount = 300 {product}
intx PrintSafepointStatisticsTimeout = -1 {product}
bool PrintSharedSpaces = false {product}
bool PrintTLAB = false {product}
bool PrintTenuringDistribution = false {product}
bool PrintVMOptions = false {product}
bool PrintVMQWaitTime = false {product}
uintx ProcessDistributionStride = 4 {product}
bool ProfileInterpreter = true {pd product}
bool ProfileIntervals = false {product}
intx ProfileIntervalsTicks = 100 {product}
intx ProfileMaturityPercentage = 20 {product}
bool ProfileVM = false {product}
bool ProfilerPrintByteCodeStatistics = false {product}
bool ProfilerRecordPC = false {product}
uintx PromotedPadding = 3 {product}
intx QueuedAllocationWarningCount = 0 {product}
bool RangeCheckElimination = true {product}
intx ReadPrefetchInstr = 0 {product}
intx ReadSpinIterations = 100 {product}
bool ReassociateInvariants = true {C2 product}
bool ReduceBulkZeroing = true {C2 product}
bool ReduceFieldZeroing = true {C2 product}
bool ReduceInitialCardMarks = true {C2 product}
bool ReduceSignalUsage = false {product}
intx RefDiscoveryPolicy = 0 {product}
bool ReflectionWrapResolutionErrors = true {product}
bool RegisterFinalizersAtInit = true {product}
bool RelaxAccessControlCheck = false {product}
bool RequireSharedSpaces = false {product}
uintx ReservedCodeCacheSize = 50331648 {pd product}
bool ResizeOldPLAB = true {product}
bool ResizePLAB = true {product}
bool ResizeTLAB = true {pd product}
bool RestoreMXCSROnJNICalls = false {product}
bool RewriteBytecodes = true {pd product}
bool RewriteFrequentPairs = true {pd product}
intx SafepointPollOffset = 256 {C1 pd product}
intx SafepointSpinBeforeYield = 2000 {product}
bool SafepointTimeout = false {product}
intx SafepointTimeoutDelay = 10000 {product}
bool ScavengeBeforeFullGC = true {product}
intx SelfDestructTimer = 0 {product}
uintx SharedDummyBlockSize = 536870912 {product}
uintx SharedMiscCodeSize = 4194304 {product}
uintx SharedMiscDataSize = 4194304 {product}
uintx SharedReadOnlySize = 10485760 {product}
uintx SharedReadWriteSize = 12582912 {product}
bool ShowMessageBoxOnError = false {product}
intx SoftRefLRUPolicyMSPerMB = 1000 {product}
bool SplitIfBlocks = true {product}
intx StackRedPages = 1 {pd product}
intx StackShadowPages = 3 {pd product}
bool StackTraceInThrowable = true {product}
intx StackYellowPages = 2 {pd product}
bool StartAttachListener = false {product}
intx StarvationMonitorInterval = 200 {product}
bool StressLdcRewrite = false {product}
bool StressTieredRuntime = false {product}
bool SuppressFatalErrorMessage = false {product}
uintx SurvivorPadding = 3 {product}
intx SurvivorRatio = 8 {product}
intx SuspendRetryCount = 50 {product}
intx SuspendRetryDelay = 5 {product}
intx SyncFlags = 0 {product}
ccstr SyncKnobs = {product}
intx SyncVerbose = 0 {product}
uintx TLABAllocationWeight = 35 {product}
uintx TLABRefillWasteFraction = 64 {product}
uintx TLABSize = 0 {product}
bool TLABStats = true {product}
uintx TLABWasteIncrement = 4 {product}
uintx TLABWasteTargetPercent = 1 {product}
bool TaggedStackInterpreter = false {product}
intx TargetPLABWastePct = 10 {product}
intx TargetSurvivorRatio = 50 {product}
uintx TenuredGenerationSizeIncrement = 20 {product}
uintx TenuredGenerationSizeSupplement = 80 {product}
uintx TenuredGenerationSizeSupplementDecay = 2 {product}
intx ThreadPriorityPolicy = 0 {product}
bool ThreadPriorityVerbose = false {product}
uintx ThreadSafetyMargin = 52428800 {product}
intx ThreadStackSize = 320 {pd product}
uintx ThresholdTolerance = 10 {product}
intx Tier1BytecodeLimit = 10 {product}
intx Tier1FreqInlineSize = 35 {C2 product}
intx Tier1Inline = 0 {C2 product}
intx Tier1LoopOptsCount = 0 {C2 product}
intx Tier1MaxInlineSize = 8 {C2 product}
bool Tier1OptimizeVirtualCallProfiling = true {C1 product}
bool Tier1ProfileBranches = true {C1 product}
bool Tier1ProfileCalls = true {C1 product}
bool Tier1ProfileCheckcasts = true {C1 product}
bool Tier1ProfileInlinedCalls = true {C1 product}
bool Tier1ProfileVirtualCalls = true {C1 product}
bool Tier1UpdateMethodData = true {product}
intx Tier2BackEdgeThreshold = 100000 {pd product}
intx Tier2CompileThreshold = 10000 {pd product}
intx Tier3BackEdgeThreshold = 100000 {pd product}
intx Tier3CompileThreshold = 20000 {pd product}
intx Tier4BackEdgeThreshold = 100000 {pd product}
intx Tier4CompileThreshold = 40000 {pd product}
bool TieredCompilation = false {pd product}
bool TimeLinearScan = false {C1 product}
bool TraceBiasedLocking = false {product}
bool TraceClassLoading = false {product rw}
bool TraceClassLoadingPreorder = false {product}
bool TraceClassResolution = false {product}
bool TraceClassUnloading = false {product rw}
bool TraceGen0Time = false {product}
bool TraceGen1Time = false {product}
ccstr TraceJVMTI = {product}
bool TraceLoaderConstraints = false {product rw}
bool TraceMonitorInflation = false {product}
bool TraceParallelOldGCTasks = false {product}
intx TraceRedefineClasses = 0 {product}
bool TraceSafepointCleanupTime = false {product}
bool TraceSuperWord = false {C2 product}
bool TraceSuspendWaitFailures = false {product}
intx TrackedInitializationLimit = 50 {C2 product}
intx TypeProfileMajorReceiverPercent = 90 {product}
intx TypeProfileWidth = 2 {product}
intx UnguardOnExecutionViolation = 0 {product}
bool Use486InstrsOnly = false {product}
bool UseAdaptiveGCBoundary = false {product}
bool UseAdaptiveGenerationSizePolicyAtMajorCollection = true {prod uct}
bool UseAdaptiveGenerationSizePolicyAtMinorCollection = true {prod uct}
bool UseAdaptiveNUMAChunkSizing = true {product}
bool UseAdaptiveSizeDecayMajorGCCost = true {product}
bool UseAdaptiveSizePolicy = true {product}
bool UseAdaptiveSizePolicyFootprintGoal = true {product}
bool UseAdaptiveSizePolicyWithSystemGC = false {product}
bool UseAddressNop = false {product}
bool UseAltSigs = false {product}
bool UseAutoGCSelectPolicy = false {product}
bool UseBiasedLocking = true {product}
bool UseBimorphicInlining = true {C2 product}
bool UseBoundThreads = true {product}
bool UseCMSBestFit = true {product}
bool UseCMSCollectionPassing = true {product}
bool UseCMSCompactAtFullCollection = true {product}
bool UseCMSInitiatingOccupancyOnly = false {product}
bool UseCodeCacheFlushing = false {product}
bool UseCompiler = true {product}
bool UseCompilerSafepoints = true {product}
bool UseConcMarkSweepGC = false {product}
bool UseCountLeadingZerosInstruction = false {product}
bool UseCounterDecay = true {product}
bool UseDepthFirstScavengeOrder = true {product}
bool UseDivMod = true {C2 product}
bool UseFastAccessorMethods = true {product}
bool UseFastEmptyMethods = true {product}
bool UseFastJNIAccessors = true {product}
bool UseG1GC = false {product}
bool UseGCOverheadLimit = true {product}
bool UseGCTaskAffinity = false {product}
bool UseHeavyMonitors = false {product}
bool UseInlineCaches = true {product}
bool UseInterpreter = true {product}
bool UseJumpTables = true {C2 product}
bool UseLWPSynchronization = true {product}
bool UseLargePages = false {pd product}
bool UseLargePagesIndividualAllocation = false {pd product}
bool UseLinuxPosixThreadCPUClocks = false {product}
bool UseLoopCounter = true {product}
bool UseLoopPredicate = false {C2 product}
bool UseMaximumCompactionOnSystemGC = true {product}
bool UseMembar = false {product}
bool UseNUMA = false {product}
bool UseNewFeature1 = false {C1 product}
bool UseNewFeature2 = false {C1 product}
bool UseNewFeature3 = false {C1 product}
bool UseNewFeature4 = false {C1 product}
bool UseNewLongLShift = false {product}
bool UseNiagaraInstrs = false {product}
bool UseOSErrorReporting = false {pd product}
bool UseOldInlining = true {C2 product}
bool UseOnStackReplacement = true {pd product}
bool UseOnlyInlinedBimorphic = true {C2 product}
bool UseOprofile = false {product}
bool UseOptoBiasInlining = true {C2 product}
bool UsePSAdaptiveSurvivorSizePolicy = true {product}
bool UseParNewGC = false {product}
bool UseParallelDensePrefixUpdate = true {product}
bool UseParallelGC := true {product}
bool UseParallelOldGC = false {product}
bool UseParallelOldGCCompacting = true {product}
bool UseParallelOldGCDensePrefix = true {product}
bool UsePerfData = true {product}
bool UsePopCountInstruction = false {product}
intx UseSSE = 99 {product}
bool UseSSE42Intrinsics = false {product}
bool UseSerialGC = false {product}
bool UseSharedSpaces = false {product}
bool UseSignalChaining = true {product}
bool UseSpinning = false {product}
bool UseSplitVerifier = true {product}
bool UseStoreImmI16 = true {product}
bool UseStringCache = false {product}
bool UseSuperWord = true {C2 product}
bool UseTLAB = true {pd product}
bool UseThreadPriorities = true {pd product}
bool UseTypeProfile = true {product}
bool UseUnalignedLoadStores = false {product}
bool UseVMInterruptibleIO = true {product}
bool UseVectoredExceptions = false {pd product}
bool UseXMMForArrayCopy = false {product}
bool UseXmmI2D = false {product}
bool UseXmmI2F = false {product}
bool UseXmmLoadAndClearUpper = true {product}
bool UseXmmRegToRegMoveAll = false {product}
bool VMThreadHintNoPreempt = false {product}
intx VMThreadPriority = -1 {product}
intx VMThreadStackSize = 512 {pd product}
intx ValueMapInitialSize = 11 {C1 product}
intx ValueMapMaxLoopSize = 8 {C1 product}
intx ValueSearchLimit = 1000 {C2 product}
bool VerifyMergedCPBytecodes = true {product}
intx WorkAroundNPTLTimedWaitHang = 1 {product}
uintx YoungGenerationSizeIncrement = 20 {product}
uintx YoungGenerationSizeSupplement = 80 {product}
uintx YoungGenerationSizeSupplementDecay = 8 {product}
uintx YoungPLABSize = 4096 {product}
bool ZeroTLAB = false {product}
intx hashCode = 0 {product}
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is server,
because you are running on a server-class machine.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value> #设置一个系统属性值,偶尔用到
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
[root@master ~]#
如下图,JVM启动后,内存中分配了这些区域(运行时数据区域),这些区域之外,任何一个类,必须要到这些数据区域里运行,任何一个类的运行都有可能依赖于其它的公共类或私有类,所以它需要一个类加载器,(所以在运行时数据区域之外,有个类加载器,负载帮用户加载类的)(可以让JVM自带的类加载器完成类的加载,也可以调用外部的类加载器)(用户可以自己定义类加载器,这是java语言受欢迎的原因,因为加载什么类完全可以手动控制的),想运行某个类,必须把这个类装载进运行时数据区域当中,,无论哪个类,包括程序自身,都要靠类加载器进行装载,,一旦装载成功了,接下来分配好内存空间以后,而且给它创建一个线程,接下来,只要轮到它执行,就可以执行了,,,,,,
真正要执行,首先要创建好一个线程,,,要运行还得依赖于java的运行引擎(JVM的执行引擎),,
所以运行时数据区域是负责内存管理,线程的创建和回收,对象的创建等,最终靠执行引擎来执行
类从加载进内存开始,到卸载出内存结束,的生命周期
类的生命周期
vLoading 加载
vVerification 验证,为了安全,为了确保,class字节流包含的信息符合虚拟机的要求,不符合规范的,不让运行,以免危害虚拟机的安全,验证包括文件格式验证,源数据验证,字节码验证等相关功能,了解就行了
vPreparation,预准备就是设置些初始值,分配些内存空间等(准备初始化变量,准备创建一个线程)
vResolution,解析,包括full引用,直接引用,间接引用等类似于mysql的parse
vInitialization,初始化是类加载过程中的最后一步,到此为止,一直是类加载器完成的功能,加载完成,就可以using执行了
vUsing,使用
vUnloading,卸载
new 生成一个对象,引用指向对象,对象有各种方法,方法可以被调用,new 一个对象,就是加载loading????加载是由加载器完成的
到底用什么类加载器,java启动的时候,可以使用-x boot classpath ?????(-classpath 或 -D<name>=<value> 来指定类文件所在位置,它里面会找到类加载器的????)指定其库文件加载路径的
类加载器本身也是一个类,是用java开发的,
JVM有众多内存空间可用,这些内存空间在运行时,我们可以监控
[root@master ~]# cd /usr/java/jdk1.6.0_21/bin/
[root@master bin]# ls #里面很多命令可以监控
appletviewer java jcontrol jstack policytool unpack200
apt javac jdb jstat rmic wsgen
ControlPanel javadoc jhat jstatd rmid wsimport
extcheck javah jinfo jvisualvm rmiregistry xjc
HtmlConverter javap jmap keytool schemagen
idlj java-rmi.cgi jps native2ascii serialver
jar javaws jrunscript orbd servertool
jarsigner jconsole jsadebugd pack200 tnameserv
[root@master bin]#
Sun JDK监控和故障处理工具:
jps, JVM Process Status Tool: 显示指定系统内所有的HotSpot虚拟机 (JVM)进程的列表信息,
jstat, JVM Statistics Monitoring Tool:收集并显示HotSpot虚拟机各方面的运行数据,java状态统计的工具
jinfo:显示正在运行的某HotSpot虚拟机配置信息,显示虚拟机的配置信息,后面跟的是虚拟机运行的进程号
jmap: 生成某HotSpot虚拟机(JVM)的内存转储快照;(map 是内存映射的意思) ,,在调试的时候才会用到.
可视化工具:
jconsole: Java的监控与管理控制台
jvisualvm: java 可视化 虚拟机,也是一个java的虚拟机控制台的可视化工具
[root@master bin]# jps #看启动了几个虚拟机进程,(hadoop时用的比较多,)这时就是jps自己,因为这里没有启动java虚拟机,启动tomcat后就可以看到了
4605 Jps
[root@master bin]#
[root@master bin]# jinfo -h
Usage:
jinfo [option] <pid>
(to connect to running process)
jinfo [option] <executable <core>
(to connect to a core file)
jinfo [option] [server_id@]<remote server IP or hostname>
(to connect to remote debug server)
where <option> is one of:
-flag <name> to print the value of the named VM flag
-flag [+|-]<name> to enable or disable the named VM flag #手动禁用或启用某个标识
-flag <name>=<value> to set the named VM flag to the given value
-flags to print VM flags
-sysprops to print Java system properties
<no option> to print both of the above
-h | -help to print this help message
[root@master bin]#
[root@master bin]# jinfo -sysprops #可以显示 -D 配置的系统属性信息,这里后面没跟pid,所以无法显示
Usage:
jinfo [option] <pid>
(to connect to running process)
jinfo [option] <executable <core>
(to connect to a core file)
jinfo [option] [server_id@]<remote server IP or hostname>
(to connect to remote debug server)
where <option> is one of:
-flag <name> to print the value of the named VM flag
-flag [+|-]<name> to enable or disable the named VM flag
-flag <name>=<value> to set the named VM flag to the given value
-flags to print VM flags
-sysprops to print Java system properties
<no option> to print both of the above
-h | -help to print this help message
[root@master bin]#
# jconsole
如下图,可连本机,可连远程主机,,,,(控制或显示本机,远程主机)
如下图,几个图,,
自己监控自己,(因为自己也是一个进程) 自己就是用java写的,自己就是一个java线程了
堆 heap, non-heap 非堆(堆之外的运行区???如计数区???)
线程数
[root@master bin]# jps
4876 JConsole
4956 Jps #此时显示了这个java线程(进程还是线程????)
[root@master bin]#
[root@master bin]# jinfo 4876 #4876是进程号(进程号还是线程号????)
Attaching to process ID 4876, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 17.0-b16
Java System Properties: #java的各种配置,属性, 这些了解下就行
java.runtime.name = Java(TM) SE Runtime Environment
sun.boot.library.path = /usr/java/jdk1.6.0_21/jre/lib/i386
java.vm.version = 17.0-b16
java.vm.vendor = Sun Microsystems Inc.
java.vendor.url = http://java.sun.com/
java.rmi.server.randomIDs = true
path.separator = :
java.vm.name = Java HotSpot(TM) Server VM
file.encoding.pkg = sun.io
sun.java.launcher = SUN_STANDARD
user.country = US
sun.os.patch.level = unknown
java.vm.specification.name = Java Virtual Machine Specification
user.dir = /root
java.runtime.version = 1.6.0_21-b06
java.awt.graphicsenv = sun.awt.X11GraphicsEnvironment
java.endorsed.dirs = /usr/java/jdk1.6.0_21/jre/lib/endorsed
os.arch = i386
java.io.tmpdir = /tmp
line.separator =
java.vm.specification.vendor = Sun Microsystems Inc.
os.name = Linux
application.home = /usr/java/jdk1.6.0_21
sun.jnu.encoding = ANSI_X3.4-1968
java.library.path = /usr/java/jdk1.6.0_21/jre/lib/i386/server:/usr/java/jdk1.6.0_21/jre/lib/i386:/usr/java/jdk1.6.0_21/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib
java.specification.name = Java Platform API Specification
java.class.version = 50.0
sun.management.compiler = HotSpot Tiered Compilers
os.version = 2.6.32-754.el6.i686
user.home = /root
user.timezone = Asia/Chongqing
java.awt.printerjob = sun.print.PSPrinterJob
file.encoding = ANSI_X3.4-1968
java.specification.version = 1.6
java.class.path = /usr/java/jdk1.6.0_21/lib/jconsole.jar:/usr/java/jdk1.6.0_21/lib/tools.jar:/usr/java/jdk1.6.0_21/classes
user.name = root
java.vm.specification.version = 1.0
java.home = /usr/java/jdk1.6.0_21/jre
sun.arch.data.model = 32
user.language = en
java.specification.vendor = Sun Microsystems Inc.
java.vm.info = mixed mode
java.version = 1.6.0_21
java.ext.dirs = /usr/java/jdk1.6.0_21/jre/lib/ext:/usr/java/packages/lib/ext
sun.boot.class.path = /usr/java/jdk1.6.0_21/jre/lib/resources.jar:/usr/java/jdk1.6.0_21/jre/lib/rt.jar:/usr/java/jdk1.6.0_21/jre/lib/sunrsasign.jar:/usr/java/jdk1.6.0_21/jre/lib/jsse.jar:/usr/java/jdk1.6.0_21/jre/lib/jce.jar:/usr/java/jdk1.6.0_21/jre/lib/charsets.jar:/usr/java/jdk1.6.0_21/jre/classes
java.vendor = Sun Microsystems Inc.
file.separator = /
java.vendor.url.bug = http://java.sun.com/cgi-bin/bugreport.cgi
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.cpu.isalist =
VM Flags:
-Dapplication.home=/usr/java/jdk1.6.0_21 #启动的jdk位置
[root@master bin]#
[root@master bin]# pwd
/usr/java/jdk1.6.0_21/bin
[root@master bin]# ls
appletviewer java jcontrol jstack policytool unpack200
apt javac jdb jstat rmic wsgen
ControlPanel javadoc jhat jstatd rmid wsimport
extcheck javah jinfo jvisualvm rmiregistry xjc
HtmlConverter javap jmap keytool schemagen
idlj java-rmi.cgi jps native2ascii serialver
jar javaws jrunscript orbd servertool
jarsigner jconsole jsadebugd pack200 tnameserv
[root@master bin]#
# jvisualvm #java虚拟机本身的配置信息都可以查看的
很多商业公司也开发了很多故障处理工具,管理工具,如IBM,惠普的eclipse,及早期的BEA的等