Open URL with Java, then close the browser [duplicate] - java

This question already has answers here:
Closing a Web Browser for a specific URL from the java program
(2 answers)
Closed 7 years ago.
I'd like to open an URL in the default browser using Java. So I am doing what the answer in this question says: Open a link in browser with java button?
It works. However, I want to automatically close that browser after some 10 seconds have passed (from Java). This is for Windows machines.
How can I achieve this?

Start the process with:
Process p = Runtime.getRuntime().exec(new String[] {"explorer", "http://google.pl"});
and after your 10 sec call:
p.destroy();

Related

Using Javacode to get the actual name of the Program that is top [duplicate]

This question already has answers here:
How to get a list of current open windows/process with Java?
(14 answers)
Closed 6 years ago.
I am currently writing a Java Application, that needs to filter the name of the Program whichs UI is front. Sorry for my bad english.
So let's say the Java App is running in Background and I open Windows -> Games -> Minesweeper then i want the App to only tell me "Active: Minesweeper". Without any additional information. Just the name "Minesweeper"
I already tried using JavaNativeAccess but I'm still unfamiliar with it.
Thanks you all in advance
You might want to look at the following link which might be of help:
How to get a list of current open windows/process with Java?

how to open program (matlab) using java? [duplicate]

This question already has answers here:
Running MATLAB function from Java
(5 answers)
Closed 7 years ago.
i have project in matlab (neural network) but my GUI is using java (netbeans) and i want to open my matlab project using that GUI. can anyone show me the code to open matlab or other program using java. thanks
You'd want something like this:
Runtime runTime = Runtime.getRuntime();
Process process = runTime.exec("matlab");
process.destroy(); // to kill the app

How to execute shell script from Java applet [duplicate]

This question already has answers here:
executing shell scripts in java script or trigger scanner from browser
(2 answers)
Closed 9 years ago.
I want to access a document scanner on client's side so I have created a shell script to perform this action. Is there any way to execute it through a browser applet? Is there a way to make it work on Fedora 18 OS that will allow me to install a plugin like twain? This how I call my script currently:
String[] cmd = {"sh test.sh", "/Path/to my/resource file"};
Runtime.getRuntime().exec(cmd)
You can use Java Web Start or a signed applet.

Using Regedit in Java [duplicate]

This question already has answers here:
Read/write to Windows registry using Java
(25 answers)
Closed 9 years ago.
How do I use regedit so as to store some deatails of my program ?
I would like to use this to store some data like the program folder, some user cofigs and also some extensions that the computer should recognize as my program's extension.
Consider using the Preferences API. Preferences.systemRoot() should let you touch the registry node at HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Prefs on a 64 bit computer with 32 bit java.

How do I determine the default browser in Windows and Linux? [duplicate]

This question already has answers here:
Looking for a Java User Agent String Parser [closed]
(2 answers)
Open a link in browser with java button? [duplicate]
(7 answers)
Closed 10 years ago.
I am designing small Java application and there is a webDriver in it. The application will collect information from a web service.
One of the requirements for this app is no particular browser dependency. That is, I don't know which browser is installed on the end user PC. As a result, I need to use the default browser. How do I do this?
in Windows :you can use browse(URI uri) function in Desktop class ,it launches the default browser to display uri
Desktop.getDesktop().browse("/////URI");

Categories