Solved

is it possible to load a web page into a browser, and then shut the browser when loaded?

Posted on 2010-09-16
10
396 Views
Last Modified: 2013-12-29
I would like to use Java to open firefox and load a web page into it.  once the page finishes loading, i would like to end firefox.  how would i do this?  

opening firefox from java is easy, and executing a kill command to stop firefox is easy too.  but how would i find out when the page finishes loading?
0
Comment
Question by:trip008vk
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33694701
<<but how would i find out when the page finishes loading?>>
I dont think you can do this in java. Since after starting the browser, for your java program the task is completed, and control is no longer with your java program. After which firefox process cannot send any signal or interrupts to your java program.

You need to check if there is any command, which can tell given a browser's PID, what are the pages loaded and their status
0
 
LVL 3

Expert Comment

by:alanpetersen
ID: 33696880
Why are you trying to do this? If you simply want to hit a URL, you can easily do that within Java (I can give some sample code for that if you like). If you are firing up Firefox because you want that as your user-agent, it's easy to set that programmatically too. Then you don't have to mess with launching/killing Firefox.
 
0
 

Author Comment

by:trip008vk
ID: 33697484
i'm doing this because i need to run some javascript code in firefox, and then have the browser close...
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 3

Expert Comment

by:alanpetersen
ID: 33697615
Have you looked into the javax.script.ScriptEngine functionality? I don't know if this will necessarily solve your problem, but it might be worth considering.

http://download.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 500 total points
ID: 33698735
look at JDIC, you can achieve this using the status update event...
0
 

Author Comment

by:trip008vk
ID: 33718555
ksivananth, could you be a little more clear as to how to use JDIC to solve my issue?

thanks!
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33722672
look at the downloadCompleted event fired when the page loading completed...
if you particular about the particular javascript function executed, you may want to change the status message from the javascript function which you can listen through JDIC. once you notified the status change event with that particular string you printed through javascript function, you can close JDIC!
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 500 total points
ID: 33722700
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33722703
0
 

Author Closing Comment

by:trip008vk
ID: 33763148
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question