Java 9 Process API

Java 9 will come with interesting features. Here is a quick review of the new Java 9 Process API.

Use Cases for the Java Process API

These are probably some ways how we are using the Java Process API:

  • To Install, configure or to communicate to other programs from Java: For example, I implemented a Java Installer to install the WebSphere Application Server into the system, and then I configure it by running a script coded in Jython executed the wsadmin tool.
  • To install specific Operating System stuff. I didn’t find any other simpler way to install Windows start menu items from Java other than by doing it in a VBScript program.
  • In my opinion, the Java Process API is in general used to integrate Java with other programs or processes. For example. I made a game in Blender and I implemented a launcher in Java. So, from Java I am calling the blender.exe passing the game.blender file as argument.

Known Problems and Workarounds

  • There are common issues in Windows when invoking commands which have spaces or stream redirections. The solution is to use instead the “cmd /C” command. This oracle blog talks about this. There is also an Apache commons-exec library apparently solving the same issues, but its kind of abandoned project.
  • Another issue when running processes is how to read from standard output and error streams properly. The solution is basically creating separate threads for reading the streams so the process don’t get stucked. There is an elegant solution in this blog.
  • On the other “side” (literally), if we want to kill a Java Process from the Operating System we may use the Java jps command to get the PID. Then, for instance, we can use kill -9 to kill it.
  • Finally. Sometimes when calling a Process it ends up hanging. Hopefully the Java 9 implementation will be more stable about this issue.

Java 9 Specification

Taking a look at the new spec I have to say the 4 new features look really nice! Having that features available, we will be able to implement a pure Java Windows “Task Manager” like; because now we will be able to get rid of some process calls to get process data.

Getting started with Java 9

  • Download the Java 9 version from
  • Install java 9 on folder /usr/lib/jvm/java-9-oracle
  • Check installation by running /usr/lib/jvm/java-9-oracle/bin/java -version

Code examples

So after reading about the new spec I got hands on. I compared the Javadoc for the 8 version and the new Java 9 and I found interesting classes like java.lang.ProcessHandle & java.lang.Process.Info. Lets see what we can do with them! (the full source code for the examples is located here):

Get PID of current and created processes

System.out.println("Running java process with PID " + ProcessHandle.current().getPid()+ ". Parent: " + ProcessHandle.current().parent().get().getPid());
Process pr = Runtime.getRuntime().exec(cmdArray);
System.out.println("Create Process with PID "+pr.getPid());

Enumerate Process List

ProcessHandle.allProcesses().forEach(e -> System.out.println(e.getPid() + " " +;

Deal with Process Trees

In this case, we want to deploy a process tree in order to kill everything afterwards. For this, we can implement a Java Process that creates the same Java Process recursively, finally we kill it.
Process ptree = RunHelper.exec(java, output, "-cp", cp, RecursiveJavaProcess.class.getName(), "3");

Compile & execute!

$ cd src/test/java
$ /usr/lib/jvm/java-9-oracle/bin/javac org/andresoviedo/tests/java9/process/
$ /usr/lib/jvm/java-9-oracle/bin/javac org/andresoviedo/tests/java9/process/
$ /usr/lib/jvm/java-9-oracle/bin/java org.andresoviedo.tests.java9.process.NewJava9ProcessAPI


From the main 4 features the spec mentions, I have tested the first 3. So where is the 4th? About dealing with hundred of sub-processes? I didn’t find in the current version any new option for doing that. Probably they are still implementing it. I don't know. However, if we want, we can now implement very easily a pure Java Task Manager GUI application for managing the system processes :)

Although I would like to know more real complex use cases to further evaluate the API, so far the promised features seems to work. Anyway, I am wondering what else would be nice to have for the future in the API. Probably a way to manage the process priority? I don’t know. For me, the API looks quite complete for now. I hope you like the new features.

Feel free to leave your comments. Thank you for reading me :)


  1. We've been waiting so long for Java 9 and it's finally here! And it's as awesome as I always imagined it would be :)

    1. IEEE Final Year projects Project Center in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. <Final Year Projects for CSE It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, project projects for cseAngular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Core Java Training in Chennai Core Java Training in Chennai

    Java Online Training Java Online Training Core Java 8 Training in Chennai Core java 9 online training JavaEE Training in Chennai Java EE Training in Chennai

  3. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. Java Training in Chennai

  4. It is no understatement to say that online gaming, and the Internet as a whole, took a massive step forward as a consequence of those two computing languages.

  5. Nice blog, here I had an opportunity to learn something new in my field. I have an expectation about your future post so please keep updates...Thanks..
    Web Designing Training in Chennai | Python Training in Chennai

  6. Your posts is really helpful for me.Thanks for your wonderful post. I am very happy to read your post. It is really very helpful for us and I have gathered some important information from this blog. Hadoop Training in Chennai | Salesforce Training in Chennai

  7. Your post is very nice. I read your blog completely it is one of the fantstic blog. Thanks for sharing.keep sharing more blogs.

    Python Online Training

  8. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..

    Informatica Training In Chennai | Hadoop Training In Chennai | Sap MM Training In Chennai


  9. Hi,
    Thanks for sharing such an informative blog. I have read your blog and I gathered some needful information from your blog.

    sap interview questions

  10. conventional medicine
    A decent blog dependably thinks of new and energizing data and keeping in mind that understanding I have feel that this blog is truly have each one of those quality that qualify a blog to be an one.I needed to leave a little remark to help you and wish you a decent continuation. Wishing you the good luck for all your blogging endeavors.

  11. Accountants Hove
    After I read and endeavor to comprehend this article lastly amazingwe are for the most part appreciative for the presence of this article can include significantly more knowledge for every one of us. much obliged to you

  12. It is really a great work and the way in which u r sharing the knowledge is excellent. Thanks for helping me to understand basic concepts. Thanks for your informative article. Java Training in Chennai | Pega Training in Chennai

  13. Personally, I really liked this casino exclusively best online casino especially the choice of games. All games are licensed and with normal returns. I really like how you can choose one-click games here and it’s like a lot of slot machines and slots in your hand.

  14. it is an interesting Article, i read this post that was very nice and useful thanks for sharing it.
    e learning

  15. thanks for your information really good and very nice web design company in velachery

  16. This is the first & best article to make me satisfied by presenting good content. I feel so happy and delighted.By Learn Digital Marketing Course Training in Chennai it will help to get Digital Marketing Course Training in Chennai.Learn Best Digital Marketing Course Training in Chennai's professional institute to get reputed job.

  17. Thank you for excellent article.You made an article that is interesting.
    Best AWS certification training courses. Build your AWS cloud skills with expert instructor- led classes. Live projects, Hands-on training,24/7 support.


  18. Awesome,Thank you so much for sharing such an awesome blog.web designing training in bangalore

  19. Such a great information for blogger i am a professional blogger thanks…

    Looking for Best Training Institute in Bangalore , India. Softgen Infotech is the best one to offers 85+ computer training courses including IT Software Course in Bangalore , India. Also it provides placement assistance service in Bangalore for IT.

  20. Great Article. Thank you for sharing! Really an awesome post for every one.

    IEEE Final Year projects Project Centers in Chennai are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation. For experts, it's an alternate ball game through and through. Smaller than expected IEEE Final Year project centers ground for all fragments of CSE & IT engineers hoping to assemble. Final Year Project Domains for IT It gives you tips and rules that is progressively critical to consider while choosing any final year project point.

    Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
    Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

  21. keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
    digital marketing training in bangalore |

  22. Really useful information.

    Data science Course in Mumbaii

    Thank You Very Much For Sharing These Nice Tips.

  23. This comment has been removed by the author.

  24. Such a wonderful article and I feel that it is best to write more on this topic. Thank you so much because i learn a lot of ideas about it. Keep posting...
    Digital Marketing Course In Kolkata
    Web Design Course In Kolkata
    SEO Course In Kolkata


  25. That is nice article from you , this is informative stuff . Hope more articles from you . I also want to share some information about cognos training online and websphere portal tutorial

  26. This was really one of my favorite website. Please keep on posting. ExcelR Digital Marketing Course Pune

  27. Effective blog with a lot of information. I just Shared you the link below for Courses .They really provide good level of training and Placement,I just Had Digital Marketing Classes in this institute,Just Check This Link You can get it more information about the Digital Marketing course.

    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

  28. Excellent Blog!!! The blog which you have shared here is more informative, This is really too useful and have more ideas and keep sharing many techniques about java. Thanks for giving a such a wonderful blog.
    Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

  29. There are many things mentioned in this article I would not have thought of on my own. This material is inspirational, interesting and it allows the readers to open up their minds to original thinking.
    Best Data Science training in Mumbai

    Data Science training in Mumbai

  30. Good post. I learn something new and challenging on sites I stumbleupon on a daily basis. It's always interesting to read content from other writers and practice a little something from their web sites.
    Digital Marketing Training Course in Chennai | Digital Marketing Training Course in Anna Nagar | Digital Marketing Training Course in OMR | Digital Marketing Training Course in Porur | Digital Marketing Training Course in Tambaram | Digital Marketing Training Course in Velachery

  31. Awesome,Thank you so much for sharing such an awesome blog.Bedroom Furniture

  32. it is an interesting Article, i read this post that was very nice and useful thanks for sharing it.

    Kids Toys

  33. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
    Data Science Institute in Bangalore

  34. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
    Data Science Certification in Bangalore

  35. Regular visits listed here are the easiest method to appreciate your energy, which is why why I am going to the website everyday, searching for new, interesting info. Many, thank you!

    Data Science Course

  36. Impressive. Your story always bring hope and new energy. Keep up the good work.

    Data Science Training

  37. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    Data Science Training Institute in Bangalore

  38. This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.

    AWS training in Chennai

    AWS Online Training in Chennai

    AWS training in Bangalore

    AWS training in Hyderabad

    AWS training in Coimbatore

    AWS training

  39. I must say you are very much concise and experienced at persuasive writing. I just loved your flair of writing.
    Data Science training in Mumbai
    Data Science course in Mumbai
    SAP training in Mumbai

  40. Explore your creative side with this course - Learn the fundamentals of writing short stories, personal essays and poems. Please visit our website to know more information.

  41. Amazing post found to be very impressive while going through this post providing the tips for software development in Java 9. Thanks for sharing and keep posting such an informative content.

    360DigiTMG Digital Marketing Course


  42. Fantastic article I ought to say and thanks to the info. Instruction is absolutely a sticky topic. But remains one of the top issues of the time. I love your article and look forward to more.
    360DigiTMG Data Science Training Institute in Bangalore


  43. This Is a Fantastic article, signifying so much information on it, These Kind of posts keeps the users attention from the Site, and continue sharing more... good luck
    Data Science Course In Bangalore With Placement

  44. I'd love to thank you for the efforts you've made in composing this post. I hope the same best work out of you later on too. I wished to thank you with this particular sites! Thank you for sharing. Fantastic sites!
    Data Science Courses in Bangalore

  45. This is a great post. This post gives a truly quality information. I am certainly going to look into it. Really very helpful tips are supplied here. Thank you so much. Keep up the great works
    Data Science Training in Bangalore

  46. Cognex offers AWS Training in Chennai using classroom and AWS Online Training globally. Cognex is the
    best aws training center in chennai providing high quality study materials and technical training.

  47. Terrific post thoroughly enjoyed reading the blog and more over found to be the tremendous one. In fact, educating the participants with it's amazing content. Hope you share the similar content consecutively.

    360DigiTMG Data Analytics Course

  48. Extraordinary blog filled with an amazing content which no one has touched this kid of subject before. Thanking the blogger for all the terrific efforts put in to develop such an awesome content. Expecting you to deliver similar contents further too and keep sharing as always.

    360DigiTMG PMP Certification Course

  49. I will really appreciate the writer for providing such an wonderful article. information provided was very useful.
    Data Analytics Course Online 360DigiTMG

  50. "Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
    Salesforce Training in Pune"

  51. Lidar or light detection and ranging is a surveying method that can help you to measure the length and distance of the surface of the earth. The measurement of lidar is highly accurate. lidar Grand Prarie , Alberta

  52. This post was really thinkable for me, please updates more information about this related blog. Visit Ogen Infosystem for quality web design and SEO Services in your budget.
    Website Designing Company in Delhi

  53. Thanks for sharing this, I actually appreciate you taking the time to share with everybody.
    Best Data Science Course In Hyderabad

  54. Now, the online store wants to propose product recommendations for each customer based on their past activity. The store got the entire information of the customers like past purchase history, products browsing the history, income, age and some more. data science course syllabus

  55. Nice Information Your first-class knowledge of this great job can become a suitable foundation for these people. I did some research on the subject and found that almost everyone will agree with your blog.
    Cyber Security Course in Bangalore

  56. I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously
    in their life, he/she can earn his living by doing blogging.Thank you for this article.
    best java online training

  57. Writing in style and getting good compliments on the article is hard enough, to be honest, but you did it so calmly and with such a great feeling and got the job done. This item is owned with style and I give it a nice compliment. Better!
    Cyber Security Training in Bangalore

  58. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    blockchain online training
    best blockchain online training
    top blockchain online training

  59. This is a really explainable very well and i got more information from your site.Very much useful for me to understand many concepts and helped me a lot.Best data science courses in hyerabad

  60. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also.
    data science course in India

  61. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
    Artificial Intelligence Course

  62. keep up the good work. this is an Ossam post. This is to helpful, i have read here all post. i am impressed. thank you. this is our site please visit to know more information
    data science training in courses

  63. Very good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work. otherwise anyone want to learn Revit MEP course so contact here- +91-9311002620 or Visit Website-

  64. I have facebook account about Java, but this topic is not so popular as I think and I have to buy facebook followers from here This the only way to get new followers

  65. We are well established IT and outsourcing firm working in the market since 2013. We are providing training to the people ,
    like- Web Design , Graphics Design , SEO, CPA Marketing & YouTube Marketing.Call us Now whatsapp: +(88) 01537587949
    :Freelancing training in Bangladesh
    Free bangla sex video:careful
    good post outsourcing institute in bangladesh

  66. iot training in chennai - IoT Training in Chennai - IoT is one of the technologies which has a lot of scope at the very same time very less number of skilled employees in this technology which means this particular technology will give a huge success rate. Join the Best IOT Training Institute in Chennai now.

    Devops training Institute in Chennai - DevOps a combination of Development and operations has an better career .Jobs opportunities are there from startup companies to big mnc. Start to learn DevOps technology soon and secure your job now.

    blue prism training in Chennai - If you choose to learn the blue prism or automation tool you are supposed to have the programming language. start to learn the blue prism training from the Best Blue prism Training Institute in Chennai.

    uipath training in Chennai - UI path technology is one of the fastest developing fields which has a lot of job opportunities such as software developer, Programmer and lot more. Join the Best Uipath Training Institute in Chennai.

    microsoft azure training in chennai -Microsoft azure technology is growing and soon it will be competitive aws. So students who start to learn Microsoft azure now will be well - paid in the future. Start to learn Microsoft azure training in Chennai.

    Chennai IT Training Center

  67. This is very good post I have read and I must appreciate you to have written this for us.Its really informative.
    Best Digital Marketing Agency in Chennai
    website design in chennai

  68. I read this article, it is really informative one. Your way of writing and making things clear is very impressive. Thanking you for such an informative article.Artificial Intelligence Training Course In Hyderabad

  69. I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
    business analytics course


Post a Comment

Popular posts from this blog

Android 3D Model Viewer Open Source

Google Drive FTP Adapter