Saturday, November 29, 2008

JPS : Differentiate between multiple java processes

The general problem which everybody faces while using multiple JVM process is that when u want to kill a particular process, u need to find out exactly by killing which process kills the program u want.
Suppose when u r running a server and an Java IDE and lets say the IDE is hanged and u want to kill it. But if we see the Task Manager there will be multiple java.exe's. We need to find out which process kills the program u want to terminate.
In that case, we have a handy tool named JPS. JPS is Java Virtual Machine Process Status Tool, which comes by default with the Java Installation.
First of all we need to find out the Process Identifier(PID) of the corresponding programs. Lets say if we run a server and IDE . We want to terminate the IDE.
** Type jps in the command prompt which will list all the Java processes running on the machine with the corresponding PIDs.
**Now we got the PID of the process which we want to kill. Lets say PID of server is 5080 and IDE is 3936.
**Now the next question is how to map this PID with the java process that is shown in the Task Manager.
**Open the Task Manager, Go to View>Select Columns> check PID.
Now the Task Manager will list all the PID's along with the process.
**Now kill the corresponding java.exe process with the correct PID given by JPS. i.e. Kill 3936, which kills the IDE process without interupting any other java processes.

So, now we can be pretty sure which process we r going to terminate !!!!


Monday, November 17, 2008

Problem with the Netbeans 6.1 installer ????

I was trying to intall netbeans-6.1-ml-windows.exe on vista and faced some inital problems. After setting them correct there was another blocker in the store for me... 

I was installing that from the command line...
D:\softwares\myeclipse>netbeans-6.1-ml-windows.exe --javahome C:\Java\jdk1.5.0_06
and it showed me "Unsupported Java VM version".

So i need to update my Java. 
My concerns in updatng the java are:
1. So when i update will it intall java 6 on my machine???
2. How to stick to java 5.x and get the latest in Tiger???
 

java -version ????

I was trying to install netbeans on vista and the installer says  

JDK 6 or JDK 5 is required for installing the NetBeans IDE. Make sure that the JDK is properly installed and run installer again.
You can specify valid JDK location using --javahome installer argument. 

so when i try to check my intalled java version number it says

C:\Users\Naresh>java -version
Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
has value '1.5', but '1.6' is required.
Error: could not find java.dll
Error: could not find Java SE Runtime Environment.

To solve this i tried everything  changing, adding and deleting the registry entries whatever i felt would solve the issue. After digging into the issue somewhere i found a pointer to look into the java.exe in the C:\Windows\System32 folder.

Here I found that the java.exe is from java 6.0, i thought of replacing this with java.exe of 5.0 and suddenly it all worked :-) . So there is nothing that we could actually change in the registry

and finally 

C:\Users\Naresh>java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)