<liclass="toctree-l2"><aclass="reference internal"href="#get-the-main-class-of-the-process-with-the-sysenv-command">4. Get the Main Class of the process with the sysenv command</a></li>
<liclass="toctree-l2"><aclass="reference internal"href="#decompile-main-class-with-jad-command">5. Decompile Main Class with jad command</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered">Questions and answers</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas">Fork me at GitHub</a></li>
<spanid="start-demo-application"></span><h2>1. Start Demo Application<aclass="headerlink"href="#start-demo-application"title="Permalink to this headline">¶</a></h2>
<p><codeclass="docutils literal notranslate"><spanclass="pre">arthas-demo</span></code> is a simple program that generates a random number every second, then find all prime factors of the number.</p>
<p>If there is no <codeclass="docutils literal notranslate"><spanclass="pre">arthas-demo.jar</span></code> locally, you can download it from here:<aclass="reference external"href="http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.taobao.arthas&a=arthas-boot&v=LATEST">Click</a></p>
<p>You can also compile code by youself:<aclass="reference external"href="https://github.com/alibaba/arthas/blob/master/demo/src/main/java/demo">View</a></p>
<div>The user to run this command <em>MUST</em> have the same privilege as the owner of the target process, as a simple example you can try the following command if the target process is managed by user <codeclass="docutils literal notranslate"><spanclass="pre">admin</span></code>: <codeclass="docutils literal notranslate"><spanclass="pre">sudo</span><spanclass="pre">su</span><spanclass="pre">admin</span><spanclass="pre">&&</span><spanclass="pre">java</span><spanclass="pre">-jar</span><spanclass="pre">arthas-boot.jar</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">sudo</span><spanclass="pre">-u</span><spanclass="pre">admin</span><spanclass="pre">-EH</span><spanclass="pre">java</span><spanclass="pre">-jar</span><spanclass="pre">arthas-boot.jar</span></code>.If you cannot be able to attach to the target process, please check the logs under <codeclass="docutils literal notranslate"><spanclass="pre">~/logs/arthas</span></code> for troubleshooting.</div></blockquote>
<p>The ‘Demo’ process is the fourth as shown above, press ‘2’ then ‘Enter’. Arthas will attach to the target process, and start to output:</p>
<divclass="highlight-bash notranslate"><divclass="highlight"><pre><span></span><spanclass="o">[</span>INFO<spanclass="o">]</span> Try to attach process <spanclass="m">71560</span>
<spanclass="o">[</span>INFO<spanclass="o">]</span> Attach process <spanclass="m">71560</span> success.
<spanid="check-the-dashboard"></span><h2>3. Check the Dashboard<aclass="headerlink"href="#check-the-dashboard"title="Permalink to this headline">¶</a></h2>
<p>Type ‘<aclass="reference internal"href="dashboard.html"><spanclass="doc">dashboard</span></a>’ and hit ‘ENTER’, a brief report on the current process will be shown as below, pls. <codeclass="docutils literal notranslate"><spanclass="pre">Ctrl+C</span></code> to stop:</p>
<spanid="get-the-main-class-of-the-process-with-the-sysenv-command"></span><h2>4. Get the Main Class of the process with the sysenv command<aclass="headerlink"href="#get-the-main-class-of-the-process-with-the-sysenv-command"title="Permalink to this headline">¶</a></h2>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span>$ sysenv | grep MAIN
<spanid="decompile-main-class-with-jad-command"></span><h2>5. Decompile Main Class with jad command<aclass="headerlink"href="#decompile-main-class-with-jad-command"title="Permalink to this headline">¶</a></h2>
<spanid="watch"></span><h2>6. watch<aclass="headerlink"href="#watch"title="Permalink to this headline">¶</a></h2>
<p>Use ‘<aclass="reference internal"href="watch.html"><spanclass="doc">watch</span></a>’ to view the return object of <codeclass="docutils literal notranslate"><spanclass="pre">demo.MathGame#primeFactors</span></code>:</p>
<p>Use <codeclass="docutils literal notranslate"><spanclass="pre">quit</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">exit</span></code> to disconnect from the current process. The Arthas instance attached to the target process continues to live inside the process, and its port is standby for further connection.</p>
<p>Use <codeclass="docutils literal notranslate"><spanclass="pre">shutdown</span></code> to have Arthas completely quit from the target process.</p>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.