Search code examples
javamavenjvmclasspathjvm-hotspot

List Java Virtual Machine on JRE


Hi i make a Utility program to find the JVM on JRE enabled machine, for this i approach this link List JVM on localhost but when i compiled this program on jre enabled machine it is not listing anything.

Again after some RnD on this, i add tools.jar and jconsole.jar on my pom.xml

<dependencies>
<dependency>
    <groupId>java.tools</groupId>
    <artifactId>javatools</artifactId>
    <version>1.0</version>
</dependency>


<dependency>
    <groupId>java.jconsole</groupId>
    <artifactId>jconsole</artifactId>
    <version>1.0</version>
</dependency>

<build>
<plugins>
    <plugin>
        <groupId>java.tools</groupId>
        <artifactId>javatools</artifactId>
        <version>1.0</version>
        <configuration>
            <downloadSources>false</downloadSources>
            <downloadJavadocs>false</downloadJavadocs>
        </configuration>
    </plugin>

    <plugin>
        <groupId>java.jconsole</groupId>
        <artifactId>jconsole</artifactId>
        <version>1.0</version>
        <configuration>
            <downloadSources>false</downloadSources>
            <downloadJavadocs>false</downloadJavadocs>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4.1</version>
        <configuration>
            <!-- get all project dependencies -->
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
            <!-- MainClass in mainfest make a executable jar -->
            <archive>
                <manifestEntries>
                    <Built-By>Ni3</Built-By>
                    <Class-Path>.</Class-Path>
                </manifestEntries>

                <manifest>
                    <mainClass>com.experiment.java.JVMFinder</mainClass>
                    <addClasspath>true</addClasspath>
                </manifest>

            </archive>

        </configuration>
        <executions>
            <execution>
                <id>make-assembly</id>
                <!-- bind to the packaging phase -->
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

</plugins>

What i am going wrong. Is it possible to list jvm on JRE enabled machine?

Thanks.


Solution

  • Some findings may be useful for others, In my machine hsperfdata_%USERNAME% not listing any running jvm id because there is no permission to current user so i give permission for fetching running jvm list. Reference

    One more thing i posted in comment that jProfiler tool do some changes on my computer. So answear to this is same. It gave permission to that folder.