开发者

How to check whether a default browser is opened in the operating system (Java)?

开发者 https://www.devze.com 2023-01-03 02:06 出处:网络
I am newbie here. During my work, I faced an interesting problem. I need to: check whether a default html browser is opened;

I am newbie here. During my work, I faced an interesting problem. I need to:

  • check whether a default html browser is opened;
  • check whether the browser is minimized/maximized (simply, a window's state);
  • get an url address typed in the browser.

If any of these conditions is not met, I have to open the browser in a maximized view with a desired url address.

I primarily wanted to do all this in Java, but it came to my mind that I should employ man开发者_如何学Pythony techniques/technologies and combine them appropriately to complete the functionality. But, which ones? That's the problem.

I just recalled Windows API, but I'm not sure if it is of any help... Some users on another forum suggested that I should consider JNI (no experience at all)... I only know how to open a default browser (e.g. with use of the 'browse(URI uri)' method of the 'java.awt.Desktop' class) - that's too little to be proud of.

Please give me some hints, maybe links to reasonable discussions, I would greatly appreciate any suggestions how to approach the problem.


None in Java API comes to mind since it's intented to be platformindependent and the retrieval of the information you're describing here is heavily platform (and webbrowser!) dependent.

If you don't worry about for example a Windows-only solution, then first write (or search) a solution in platform-native language, like C/C++ and then call this in Java with help of Java Native Interface (JNI).

0

精彩评论

暂无评论...
验证码 换一张
取 消