jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Run mozilla or konqueror from java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Run mozilla or konqueror from java application" Watch "Run mozilla or konqueror from java application" New topic

Run mozilla or konqueror from java application

igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
Hello, I would please like to know how to run� mozilla
and konqueror from a java application running on RedHat Linu�x or
anyother linux variant if the installation directory is stan�dard. For
windows machines I know where to find explorer, notepad e.t.�c but not
for Linux.
So looking at this code for windows

String cmd = "C:\\WINNT\\system32\\notepad.exe
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec(cmd);

How would I change it to run in linux and open a particular �file.
Thanks a lot.
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

So long as you know where an executable is you can run it. From your examples the only one which is likely to succede is an attempt to run notepad, since on XP notepad.exe has been deemed a system file. Of course that doesn't stop someone from deleting/moving it - its just a little harder. On pre-XP Windows machines you don't have the same assurance. Linux doesn't have any requirements that a particular application must be installed in a particular location. If you want to include the running of another application within your Java app, you are probably best to get the user to point to its location and store that info somewhere your app can get at it. Of course this is not foolproof, but there's not really much else you can do.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
this is really more of a Linux/Unix forum topic, but... if you know you're running on a fairly standard unix-like OS, you can use the "which" command to find the location of executables, so long as the executables you're looking for are in the current $PATH.

that is, if (for example) firefox is (1) installed, and (2) can be started by the user from the command line without the user having to spell out its location, then "/usr/bin/which firefox" should return a string holding the fully qualified path to the "firefox" binary.

/usr/bin/ is, i believe, spelled out somewhere as the standard location for the "which" command. i'd be surprised to find it ever installed elsewhere, though i suppose /bin/ might be another place to look for it. i guess it's possible for a Unix-like system to not have a "which", but that would surprise me even more.

if all else fails, you can always run a "find". "find" is in /usr/bin/ on every system i know of.
I agree. Here's the link: http://aspose.com/file-tools
subject: Run mozilla or konqueror from java application
It's not a secret anymore!