0

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.

Nitin Parashar
  • 227
  • 3
  • 13
  • As far as I know, you need a JDK for that. – Holger Jun 08 '18 at 10:26
  • Or any workaround which help me to achieve this – Nitin Parashar Jun 08 '18 at 11:24
  • Actually my client machine have only jre installed and i find out list of jvm process through code but listed code return zero always , is there any approach for solve this issue. – Nitin Parashar Jun 08 '18 at 11:52
  • Hi @Holger i just see jProfiler which list running jvm on jre enabled machine. I am new to this stuff, can you guide me , how they do it ? – Nitin Parashar Jun 08 '18 at 13:18
  • Browse `/tmp/hsperfdata_` directories - they contain files named by PIDs of running Java processes. That's exactly what `jps` does under the hood. – apangin Jun 09 '18 at 00:13
  • @apangin , thanks for the information but jps also give details of process name , so we have to read this file for process name – Nitin Parashar Jun 10 '18 at 18:13
  • @apangin , jps is not working on those machine where only jre is installed, in such scenario i couldn't get running jvm, any help will be thanksful – Nitin Parashar Jun 12 '18 at 05:20
  • @apangin Hi i see a link "https://stackoverflow.com/questions/45053288/virtualmachine-list-returns-empty-list#" in which you said bundle jdk with your application, i am using javaFX8 for bundling, and everytime it bundle jre instead of jdk, can you guide me how can i do this ? Thanks in advance – Nitin Parashar Jun 14 '18 at 06:15
  • How to do what? Copy one directory to another? No idea. – apangin Jun 14 '18 at 09:36
  • @apangin whenever i build my javafx project it took jre from jdk path instead of jdk, so my question is that how can i take full jdk instead of jre in native application. – Nitin Parashar Jun 14 '18 at 10:34
  • @apangin I look in windows 10 machine the directory /tmp/hsperfdata_ still empty? Why i could not get any specific reason – Nitin Parashar Jun 24 '18 at 12:40
  • Temporary directory on Windows is obviously not `/tmp`, but `C:\Users\%USERNAME%\Local Settings\Temp\hsperfdata_%USERNAME%` – apangin Jun 24 '18 at 13:47
  • @apangin ya it is, i check directory but it will not listed running pid of java's. Don't know why, one more thing i make an application in which i bundle jre and load attach.dll using system.loadlibrary() it is running on my machine but not run on jre enable machine. Help me to solve this problem. Going Stuck. – Nitin Parashar Jun 26 '18 at 10:35
  • @apangin, one more finding after installing jProfiler tool on computer, it do some changes on computer, what changes are they? Don't know. After that my code works fine. can you tell me what types of changes it made, Thanks. – Nitin Parashar Jun 26 '18 at 13:53

1 Answers1

1

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.

Nitin Parashar
  • 227
  • 3
  • 13