3

Introduction

In order to avoid a reboot or occurrence of a pop-up which requests to reboot the OS if a newer version of Java will be installed silently, all processes which are using Java have to be killed.

Just killing java.exe by executing the following command:

taskkill /im java.exe /f

does not solve the issue as some processes will continue to use java, e.g. postgresql JDBC, webbrowsers, tomcat, eclipse.

If all processes which are using Java are killed before Java will be installed silently, the OS will not be rebooted.

The approach to kill processes individually which are using java is not a persistent solution as if another program will be installed in the future which will use java and not be killed, the system will be rebooted again if java will be installed silently.

Question

How to find all processes which are using java and kill them all to avoid OS will be rebooted or a pop up will occur which requests to reboot the system if Java will be installed silently?

030
  • 2,588
  • 8
  • 26
  • 40
  • 1
    One way would be to get a list of all processes (running processes), and decipher whether they are java based, then kill the java based ones. So you need a command that determines if a process is java based. I am blessed in not having any java programs to test, but maybe this http://gnuwin32.sourceforge.net/packages/file.htm will show whether a process is java based. otherwise you need some other method. – barlop Jun 14 '14 at 18:18
  • The program has been installed. `file --help` has been executed and a number of commands appears. Which of these should be used in order to determine which processes are using Java? `file /path/to/java` results in `C:\Program Files\Java\jdk1.8.0_05\bin\java.exe; PE32+ executable for MS Windows (console) Mono/.Net assembly`. – 030 Jun 15 '14 at 01:33
  • That means java,exe is not written in java. And that makes sense that java.exe wouldn't be written in java. – barlop Jun 15 '14 at 05:00
  • The same result for `Apache Directory Studio` (C:\Program Files\Apache Directory Studio\Apache Directory Studio.exe; PE32+ executable for MS Windows (GUI) Mono/.Net assembly) and `Tomcat` (C:\Program Files\Apache Software Foundation\apache-tomcat-8.0.8\bin\tomcat8.exe; PE32+ executable for MS Windows (console) Mono/.Net assembly) which are neither Java based nor using java, while java is required to run these programs. – 030 Jun 15 '14 at 09:02
  • Maybe they are fundamentally not java applications. http://www.coderanch.com/t/477457/vc/Isn-Main-Parts-Eclipse-Written "eclipse.exe is a Windows app that hosts the JVM via JNI. Actually, the same could be said for java.exe, javac.exe and most of the other *.exe files in java_home/bin!" " This might shed some light: http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/invocation.html#wp9502 " That might be why apparently it doesn't use java.exe However,I note you found that it thought Eclipse used Java.. So, I don't know what's going on there. Why it differs for Eclipse and Apache DS – barlop Jun 15 '14 at 09:17
  • 1
    Perhaps you could ask in stackoverflow if eclipse and apache ds use java in a fundamentally different way such that the file command sees them differently.. And what is the difference in how java can be used, to cause that difference with the file command – barlop Jun 15 '14 at 09:20
  • http://stackoverflow.com/questions/24228467/gnuwins-file-command-indicates-programs-are-net-based-while-these-require-jav – 030 Jun 15 '14 at 10:00
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/15117/discussion-between-barlop-and-utrecht). – barlop Jun 15 '14 at 11:45

1 Answers1

4

How to kill process depends on what OS you use. But to find Java processes you can use jcmd -l command. This command list all java processes on local your machine.

Zdzisiek
  • 56
  • 1
  • This command indicates that eclipse is using java. When Eclipse has been killed, the command indicates that none of the programs are using java, while firefox is running and apacheds is still listening on port 10389. – 030 Jun 14 '14 at 18:48
  • This command does indicate that `some` processes are using java. It is not able to show `all processes which are using java`. – 030 Jun 15 '14 at 09:04
  • It is because `jcmd` shows processes working in that moment. Firefox starts java only to run applet and then don't use java after that. I don't known any universal method to find all processes which occasionally use java. But process which don't use java in that moment shouldn't block install new version of java (but I don't test this). – Zdzisiek Jun 15 '14 at 16:52