Elmer
Elmer

Reputation: 377

How to run a jnlp file with Java?

I have a JNLP file, normally I will execute with console (Linux) and works perfect.

javaws launch.jnlp 

But now I have to run from Java code, I tried this...

Process p = Runtime.getRuntime().exec(new String[]{"path/to/.jnlp"});
p.waitFor();

Not working, as it should run.

Upvotes: 5

Views: 18046

Answers (2)

Elmer
Elmer

Reputation: 377

This is my solution:

Process exec = Runtime.getRuntime().exec("javaws /var/www/Projects/jnlp/jnlp1/launch.jnlp");
exec.waitFor();

In linux:

  1. give execute permissions to the file .jnlp.
  2. Add javaws in the path of the function:

    Runtime.getRuntime().exec("javaws Path/to/jnlp");
    

Upvotes: 1

Andrew Thompson
Andrew Thompson

Reputation: 168825

It the.jnlp is in user.home it is as simple as:

File f = new File(System.getProperty("user.home"));
f = new File(f, "the.jnlp");
Desktop.getDesktop().open(f); // Launches the associated application to open the file.

Upvotes: 1

Related Questions