- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Java code to launch browser on HP-UX 11.0
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 03:22 PM
10-21-2002 03:22 PM
Runtime.getRuntime().exec(cmd)
where
cmd = netscape http://somepage.com
Netscape is located in /opt/netscape and this is in my PATH variable and it is set to my default web browser for NNM. Is there anything I am missing, such as a patch or something? I'm using HP-UX 11.0 and Netscape 4.79 JRE 1.4.0.01
I have code similar to that above where cmd = netscape -remote openURL(http://somepage.com) This displays my web page OK as long as the browser is already open.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 04:42 PM
10-21-2002 04:42 PM
Re: Java code to launch browser on HP-UX 11.0
Quick questions-
- Are you getting any errors on the screen when this code is executed?
- Is your environment variable (DISPLAY) set when this code is executed?
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2002 05:25 PM
10-21-2002 05:25 PM
Re: Java code to launch browser on HP-UX 11.0
Yes, the DISPLAY variable is set. DISPLAY=lucy:0.0
I am catching the exception, "process hasn't exited" using the following code fragment:
Process p = Runtime.getRuntime().exec(cmd);
try{
exitCode = p.exitValue();
}
catch(IllegalThreadStateException itse){
}
note: cmd=netscape http://somepage.com
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 01:24 AM
10-23-2002 01:24 AM
Re: Java code to launch browser on HP-UX 11.0
example:
$ cat $HOME/bin/url
LOG=$HOME/.`basename $0`.log
NOW=`date '+%y%m%d_%H%M%S'`
echo $NOW $* >> $LOG
echo $* #>2&
date #>2&
if [ X$DISPLAY = X ] ; then export DISPLAY=$IP:0.0 ; fi
/opt/netscape/netscape -install -display $DISPLAY -remote "openURL ( $* ,new-window)"
#The End.
$url www.hp.com #opens a new browser window with http://www.hp.com
taking this a step further you may have
$cat google
url www.google.com
#The End.
$
you get the idea... not sure if that really helps for java- however, worth to try.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 04:35 AM
10-23-2002 04:35 AM
Re: Java code to launch browser on HP-UX 11.0
the "process has not exited" error is logical (and means netscape is still running). There is either something wrong in your DISPLAY or your PATH variable. Try to put them in your code, or use a wrapper script as Thomas suggested (good idea, actually). It is also safer to pass the exec() method a string array containing the options passed to the program you want to start.
The attached code worked on my system - it opens netscape with the URL "http://www.hp.com".
Hope it helps...
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2002 10:19 AM
10-23-2002 10:19 AM
Re: Java code to launch browser on HP-UX 11.0
I've tried your code and I get the same behavior as I do with my code, (i've added process.waitfor() to eliminate the exception). In other words, it loads the web page when the browser is up, but seems to do nothing if the browser is not up, including no errors.
The same code works fine on a Solaris machine, so I don't think it is a Java issue. I think the problem might be with a path/environment setting or perhaps a patch that has to be installed.
Anyone have any other recommendations? Are others using the same OS? HP-UX 11.0, Netscape 4.79, JRE 1.4
Regards,
ken
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2002 03:29 AM
10-24-2002 03:29 AM
SolutionI tried it again on a different HP-UX machine and it didn't open netscape there, either. The only way to make it work was making a script calling netscape with the necessary parameters (display, URL) and call this script (startnetscape.sh) from the java program. That definitely worked. This seems to be an issue specifically with netscape, though. Starting e.g. xclock directly from the java program was no problem.
Regards
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2002 09:28 PM
10-24-2002 09:28 PM
Re: Java code to launch browser on HP-UX 11.0
I did some testing by getting the input stream from the runtime process used to call netscape from the Java code. I received an error that said I should check the XFILESEARCHPATH, XUSERFILESEARCHPATH, and one other variable (i'm at home right now so I don't recall the name). Anyway, I did an echo $var on all three and none were set. I tried adding them to my .dtprofile and setting the path to netscape, but it still didn't work.
I switched to using Netscape 6.2 and all is well now. I am able to launch the browser with my original Java code. One difference: on Netscape 4.79, if the process fails (browser not open), the exitValue() returns a value other than 0 (1). On Netscape 6.2, when the process fails (browser not open), the exitValue() returns 0. So, just have to code for those differences.
Regards, and thanks for everyone's help