-
opening IE window from JAva Application
Im writing a java application (standalone, not applet) and Im trying to get
it (the application) to open an IE window or NEtscape and get it to load
a url from the program..
(program sends URL to broswer, and opens a new one if browser window is not
open)
Is this possible to do? if so, any help or suggestions..
thanks
-
Re: opening IE window from JAva Application
Patrick <luker001@bama.ua.edu> wrote in message
news:392233e5$1@news.devx.com...
> Im writing a java application (standalone, not applet) and Im trying to
get it (the application) to open an IE window or NEtscape and get it to load
a url from the program.. (program sends URL to broswer, and opens a new one
if browser window is not open) Is this possible to do? if so, any help or
suggestions..
> thanks
The following code works on my Windows system:
public class StartBrowser extends Object
{
static public void main(String args[]){
try {
Runtime.getRuntime().exec("start
http://antwrp.gsfc.nasa.gov/apod/astropix.html");
} catch(java.io.IOException e) {}
System.exit(0);
}
}
-
Re: opening IE window from JAva Application
I believe the RunTime Object will do what you want (i.e. execute an external
program); but it won't be portable.
http://java.sun.com/docs/books/tutor...m/runtime.html
"Patrick" <luker001@bama.ua.edu> wrote:
>
>Im writing a java application (standalone, not applet) and Im trying to
get
>it (the application) to open an IE window or NEtscape and get it to load
>a url from the program..
>(program sends URL to broswer, and opens a new one if browser window is
not
>open)
>
> Is this possible to do? if so, any help or suggestions..
>thanks
-
Re: opening IE window from JAva Application
"Paul Clapham" <pclapham@core-mark.com> wrote:
>
>Patrick <luker001@bama.ua.edu> wrote in message
>news:392233e5$1@news.devx.com...
>> Im writing a java application (standalone, not applet) and Im trying
to
>get it (the application) to open an IE window or NEtscape and get it to
load
>a url from the program.. (program sends URL to broswer, and opens a new
one
>if browser window is not open) Is this possible to do? if so, any help
or
>suggestions..
>> thanks
>
>The following code works on my Windows system:
>
>public class StartBrowser extends Object
>{
> static public void main(String args[]){
> try {
> Runtime.getRuntime().exec("start
>http://antwrp.gsfc.nasa.gov/apod/astropix.html");
> } catch(java.io.IOException e) {}
> System.exit(0);
> }
>}
>
>
>
I am actually getting an IO Exception when I try this code. Any suggestions?
-
Re: opening IE window from JAva Application
Ken <kenneth.johns@eds,cin> wrote in message
news:393d6dc6$1@news.devx.com...
>
> "Paul Clapham" <pclapham@core-mark.com> wrote:
> >
> >public class StartBrowser extends Object
> >{
> > static public void main(String args[]){
> > try {
> > Runtime.getRuntime().exec("start
> >http://antwrp.gsfc.nasa.gov/apod/astropix.html");
> > } catch(java.io.IOException e) {}
> > System.exit(0);
> > }
> >}
> >
> I am actually getting an IO Exception when I try this code. Any
suggestions?
The exec() method will throw an IOException if the command you give it to
execute is invalid. This could happen if your PATH doesn't contain the
directory that includes the Windows program START.EXE. That's
C:\Windows\Commands on my Windows/98 system.
-
Re: opening IE window from JAva Application
"Paul Clapham" <pclapham@core-mark.com> wrote:
>
>Ken <kenneth.johns@eds,cin> wrote in message
>news:393d6dc6$1@news.devx.com...
>>
>> "Paul Clapham" <pclapham@core-mark.com> wrote:
>> >
>> >public class StartBrowser extends Object
>> >{
>> > static public void main(String args[]){
>> > try {
>> > Runtime.getRuntime().exec("start
>> >http://antwrp.gsfc.nasa.gov/apod/astropix.html");
>> > } catch(java.io.IOException e) {}
>> > System.exit(0);
>> > }
>> >}
>> >
>> I am actually getting an IO Exception when I try this code. Any
>suggestions?
>
>The exec() method will throw an IOException if the command you give it to
>execute is invalid. This could happen if your PATH doesn't contain the
>directory that includes the Windows program START.EXE. That's
>C:\Windows\Commands on my Windows/98 system.
>
>
>Do you know if there is a command(like start.exe) that works on all windows
environments? I am running NT, but user of the app. I'm creating should
be able to run any windows platform.
-
Re: opening IE window from JAva Application
Try the following code:
public class Browser {
public static void main (String argv[]) throws Exception {
Runtime.getRuntime().exec
("rundll32 url.dll,FileProtocolHandler http://www.yahoo.com/");
}
}
Thanks
Sheel Khanna
"Ken" <kenneth.johns@eds,cin> wrote:
>
>"Paul Clapham" <pclapham@core-mark.com> wrote:
>>
>>Patrick <luker001@bama.ua.edu> wrote in message
>>news:392233e5$1@news.devx.com...
>>> Im writing a java application (standalone, not applet) and Im trying
>to
>>get it (the application) to open an IE window or NEtscape and get it to
>load
>>a url from the program.. (program sends URL to broswer, and opens a new
>one
>>if browser window is not open) Is this possible to do? if so, any help
>or
>>suggestions..
>>> thanks
>>
>>The following code works on my Windows system:
>>
>>public class StartBrowser extends Object
>>{
>> static public void main(String args[]){
>> try {
>> Runtime.getRuntime().exec("start
>>http://antwrp.gsfc.nasa.gov/apod/astropix.html");
>> } catch(java.io.IOException e) {}
>> System.exit(0);
>> }
>>}
>>
>>
>>
>I am actually getting an IO Exception when I try this code. Any suggestions?
-
Re: opening IE window from JAva Application
I have used both "rundll32 url.dll" and "start", and have found that "start"
was working in more cases than the other one.
There are several issues with the Runtime object you have to take into account.
First of all the exec() command does not recognize built-in commands (like
dir, and possibly start also).
The only way to get around is by starting up the command.com from the exec()
method, and then sending any commands to the output stream you get from the
Runtime Object.
It is a bit dirty working with the runtime environment.
-
Re: opening IE window from JAva Application
"Ken" <kennethjohns@excite.com> wrote:
>
>"Paul Clapham" <pclapham@core-mark.com> wrote:
>>
>>Ken <kenneth.johns@eds,cin> wrote in message
>>news:393d6dc6$1@news.devx.com...
>>>
>>> "Paul Clapham" <pclapham@core-mark.com> wrote:
>>> >
>>> >public class StartBrowser extends Object
>>> >{
>>> > static public void main(String args[]){
>>> > try {
>>> > Runtime.getRuntime().exec("start
>>> >http://antwrp.gsfc.nasa.gov/apod/astropix.html");
>>> > } catch(java.io.IOException e) {}
>>> > System.exit(0);
>>> > }
>>> >}
>>> >
>>> I am actually getting an IO Exception when I try this code. Any
>>suggestions?
>>
>>The exec() method will throw an IOException if the command you give it
to
>>execute is invalid. This could happen if your PATH doesn't contain the
>>directory that includes the Windows program START.EXE. That's
>>C:\Windows\Commands on my Windows/98 system.
>>
>>
>>Do you know if there is a command(like start.exe) that works on all windows
>environments? I am running NT, but user of the app. I'm creating should
>be able to run any windows platform.
Remove the "start" from the exec() function leaving only the url as a string.
This will make to code above work. It worked for me so I hope this helps.
Al
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|