wood burning stoves 2.0*
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
Author

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
C:\\IgwesTips.txt";
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
Bartender

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Run mozilla or konqueror from java application
 
Similar Threads
newbie question
Open url from Servlet
web browser for linux: new mozilla is amazing!
Run a batch file in a Windows system
trying to run a linux commands from a java app