0

How can I auto launch JNLP file "Programmatically". I have been able to auto-download the JNLP file but then I have to click on the downloaded file to run it. I'm aware that I can 'open' it every time instead of 'saving' it and remembering this choice. But this is not what I want, I cannot tell client to open the file every time.

Can this be done programmatically?

I suspect that this(opening JNLP instead of saving, programmatically) can not be done, but I absolutely have no idea, any help would be appreciated.

Mithilesh Tipkari
  • 697
  • 1
  • 10
  • 16
  • Run it through [`javaws`](https://docs.oracle.com/javase/7/docs/technotes/tools/share/javaws.html), is that what you are looking for? – TT. Feb 19 '18 at 09:05

1 Answers1

0

Yes launching a JNLP file programmatically can be done, see below code is using Apache common io to copy streams (Line 3) but there are different ways to copy streams:

final File jnlp = File.createTempFile("temp", ".jnlp");
final URL url = new URL("http://your_jnlp_file_url");
IOUtils.copy(url.openStream(), new FileOutputStream(jnlp));
Desktop.getDesktop().open(jnlp); 

I have based my code from below stack overflow question where one of the answers show how to call JNLP URL programmatically:
Combination of Launch4J and Java Web Start?

alejob2k
  • 53
  • 8
  • While this may answer the question, [it is necessary](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and ideally provide the link for reference. Your post should stand alone from any other resource; [consider what would happen](https://en.wikipedia.org/wiki/Link_rot) if that site went down in the future! – Neuron Apr 23 '18 at 02:46
  • Thank you for the advice, I was unsure if redundancy or simplicity was the way to go. – alejob2k Apr 24 '18 at 04:15
  • If you ever ask yourself such questions (as I often do), just google it. Such questions have usually already been discussed and answered on either [stackoverflow meta](https://meta.stackoverflow.com/) or [StackExchange meta](https://meta.stackexchange.com/) – Neuron Apr 24 '18 at 04:18