Java
Tools
Visual VM
- javaRoot/bin/jvisualvm 이며 command tools이 아님. java 5에서 추가됨.
- java가 사용하는 포트 확인
- 전재 : 방화벽 포트는 9090일려 있고, jconsole, visualVM도 9090으로 보려한다.
- 진행. 톰켓 기동시 다음 옵션을 추가했다.
-Dcom.sun.management.jmxremote.port=9099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=MY_HOST_IP
- rimregistry에 9090을 등록했다.
./rmiregistry 9090&
- jstatd를 실행한다.
jstatd -J-Djava.security.policy=tools.policy -p 9090 - tools.policy는 다음과 같다.
grant { permission java.security.AllPermission; };
- 다음 명령어로 jstatd의 사용포트를 알아낸다.
#jstatd의 PID확인 ps -ef | grep java #port 확인 lsof -p pid | grep TCP
- 이론상 여기서 알아낸 포트로 접속을 하면 되야 하는게 아닌가. 생각중.
참조
- http://xrath.com/javase/ko/6/docs/ko/technotes/tools/solaris/rmiregistry.html
- http://xrath.com/javase/ko/6/docs/ko/technotes/tools/index.html
- http://stackoverflow.com/questions/1609961/visualvm-over-ssh
- http://runtime32.blogspot.com/2009/07/troubleshooting-remote-java-application.html
- http://imhotk.tistory.com/archive/201102
- http://pllab.kw.ac.kr/j2seapis/tooldocs/share/jstatd.html
- http://stackoverflow.com/questions/1051817/unable-to-connect-to-tomcat-using-visualvm
- http://avatar72.tistory.com/101
jstat
#PID가 20700인 자바의 GC를 3초마다 갈무리해보겠음.
jstat -gc -h20 20700 3000
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
54528.0 56512.0 0.0 1224.0 146496.0 144694.5 786432.0 87520.6 262144.0 52468.0 17 0.422 1 0.410 0.833
54528.0 56512.0 0.0 1224.0 146496.0 144806.0 786432.0 87520.6 262144.0 52468.0 17 0.422 1 0.410 0.833
54528.0 56512.0 0.0 1224.0 146496.0 144956.7 786432.0 87520.6 262144.0 52468.0 17 0.422 1 0.410 0.833
54528.0 56512.0 0.0 1224.0 146496.0 145370.1 786432.0 87520.6 262144.0 52468.0 17 0.422 1 0.410 0.833
54528.0 56512.0 0.0 1224.0 146496.0 145618.9 786432.0 87520.6 262144.0 52468.0 17 0.422 1 0.410 0.833
54528.0 56512.0 0.0 1224.0 146496.0 145908.5 786432.0 87520.6 262144.0 52468.0 17 0.422 1 0.410 0.833
참조
유용한 내용
- null check
// 1. bad if (param.equals("cust_id")) {} // 2. good if (param != null && param.equals("cust_id")) {} // 3. good, too if ("cust_id".equals(param)) {}
reference : http://tazz.tistory.com/30
- startsWith() : 반환값 블림. javascript의 indexOf와 같음. String에서 특정 문자열 찾기.
- 캐스팅
// 문자->숫자 캐스팅 String a = "10"; int b = Integer.parseInt(a); // 숫자->문자 캐스팅 int a = 10; String b = String.value(a);
- 숫자명 문자 포멧팅 (콤마 찍기)
import java.text.* DecimalFormat df = new DecimalFormat("#.##0.00"); String num = "3000"; out.pringln(df.format(num)); //3,000.00 output.
