This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can one run a native application like notepad within a java application

 
Adeiza Yusuf
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please i just want to find out if its possible to run a native application like notepad from my java code.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can just invoke it with Runtime.exec() but before doing that read this article.
 
Adeiza Yusuf
Greenhorn
Posts: 24
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Wouter, i read the article about the flaws and i have even learnt a new way to do it without the flaws of the Runtime. i used the Desktop class instead. your answer lead me to knowing something new. I really appreciate it.


this is what i have used.

 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a very good solution for opening files (with their preferred application). For running applications / commands java.lang.Process (through ProcessBuilder or Runtime.exec) is still the way to go.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like Adeiza's solution, because it will use the user's preferred text editor, which isn't necessarily Notepad.
 
Kr Manish
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Process is much more general and not specialized like the Desktop class. So depends. OP asked for an application though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic