简体   繁体   English

如何使用Java运行jnlp文件?

[英]How to run a jnlp file with Java?

I have a JNLP file, normally I will execute with console (Linux) and works perfect. 我有一个JNLP文件,通常我将使用控制台(Linux)执行并且运行良好。

javaws launch.jnlp 

But now I have to run from Java code, I tried this... 但是现在我必须从Java代码运行,我尝试了这个方法...

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

Not working, as it should run. 无法正常运行,因为它应该运行。

It the.jnlp is in user.home it is as simple as: the.jnlpuser.home它很简单:

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.

This is my solution: 这是我的解决方案:

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

In linux: 在Linux中:

  1. give execute permissions to the file .jnlp . 授予文件.jnlp执行权限。
  2. Add javaws in the path of the function: 在函数的路径中添加javaws

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM