Hey Chris,
Thank you very much.
It works !! Great.
Also one more thing..
Can I print the name of running java application using shell script?
What do you mean "name"? The "name" is Java. Another thing you could do (depends on how flexible your organisation is about this), is to create links to java with different names, thereby allowing the program to run under a different "name" than java.
I.E. create a /user/java link that always points to the "current" version of java. Then create another directory such as, say, /user/jprogs. Then, in that directory create links to the java command. So, say you have an application under the project name "someApp". You do
ln -s /usr/java/jre/bin/java /user/jprogs/someApp
(assuming /usr/java points to a jdk, if it points to a jre then remove the "jre" from above").
In this way your app processes each have a distinictive name without having to redo links (except for the /usr/java link) when you upgrade your jdk/jre.
It also makes it easy to switch from one version of java to another easily. Say you upgrade your jdk. Normally, you then have to go through all your apps and make sure they are using the "new" version. Then there is a problem and you want to "downgrade" back to the old version. Now you have to go through all the apps again. With the /usr/java link, you simply have to make sure all apps are configured with that, and then you can change the link at will to switch from version to version.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,484
Solved Threads: 494
Skill Endorsements: 16
Did you try out my suggestions in that post? Otherwise, have fun, because for one, you have to hop that the complete command, with options to the vm, is not so long that the class name isn't even retained in the ps listing. And, if it is, you need to parse that that line and using cut, sed, awk, or something similar try to cut out the "name" and differentiate it from the vm arguments, as well as any arguments that might have been fed into it. As the number of arguments (both to the VM and the app) can, obviously, vary, there is no "surefire" way of doing this in a "non-complex" generic manner.
Then again, since you're controlling it from the script that starts it, that "xxx" from the first reply is your name, so what else do you want?
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,484
Solved Threads: 494
Skill Endorsements: 16