Java Reverse Base export class two in memory

Source: Internet
Author: User
Tags export class

We may sometimes encounter situations where javaagent cannot be used temporarily, such as a web app restart on a server that is too time consuming, which we can consider using the following method.

With Dumpclass, the Dumpclass is currently poorly performing on windows and is recommended for use on Linux

Dumpclass Project Address

Https://github.com/hengyunabc/dumpclass

Http://central.maven.org/maven2/io/github/hengyunabc/dumpclass/0.0.2/dumpclass-0.0.2.jar


You need to configure the path before using Dumpclass

Edit ~/.BASHRC

sudo gedit ~/.BASHRC

In

Export Classpath=.:${java_home}/lib:${jre_home}/lib

Post-add

Export Classpath=.:${java_home}/lib:${jre_home}/lib:${java_home}/lib/tools.jar:${java_home}/lib/dt.jar:${java_ Home}/lib/sa-jdi.jar

Make environment variables effective

SOURCE ~/.BASHRC


How to use

Use JPS to view running Java processes first

[Email protected]:~$ jps4965 Jps2361 org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar2605 AppServer

We need to dump the process for appserver, the process ID to write down

Class after which the employee ends in the dumpappserver process

Java-jar Dumpclass-0.0.2.jar 2605 *employee out--classloaderprefix

2605 for the dump process, *employee represents the class terminated with the employee, out is the exported directory


The first dump may encounter problems that prompt "Can ' t attach to the process"

Cd/etc/sysctl.d

There is a file named "10-ptrace.conf" in this directory,

sudo nano 10-ptrace.conf

Open the file with Superuser privileges and change the inside line Kernel.yama.ptrace_scope = 1 to Kernel.yama.ptrace_scope = 0

Save and exit and restart the system.

(If you wonder why you should change it, take a good look at the notes in that file)



Java Reverse Base export class two in memory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.