This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure 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
  • 0
  • 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
  • 0
  • 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
  • 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: 20380
46
Chrome Eclipse IDE Java Windows
  • 0
  • 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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • 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
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic