Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for answer to Running a Java function from a webpage? by Markus A.

Current License: CC BY-SA 3.0

Post Revisions

13 events
when toggle format what by license comment
Dec 7, 2012 at 15:11 comment added anon Ah, so relative directories work. That's awesome, and I think I'll do that. Thanks. So just to make certain, it HAS to be a .jnlp file? That could cause problems what with it also being a bukkit plugin, as Bukkit can't read anything but .jar files. If it's possible to open a .jar file from a .jnlp then that would work. Also, how do I make a .jnlp? Would I simply export it with that extension?
Dec 7, 2012 at 12:53 comment added Markus A. Ah! That makes more sense then... If they come in the same .zip file, you probably know the relative paths. So simply package the jnlp file in the same directory as your jar file and link to it with a relative link from the directory in which your page resides. For example, put the webpage (index.html) into the root folder of the zip and then have a subdirectory "app" and then simply do <a href="app/myapp.jnlp">. That should do the trick...
Dec 5, 2012 at 22:22 comment added anon Sorry, I feel like I REALLY should have mentioned this before.... Both the webpage AND the .jar file are on the computer - the webpage comes in the same .zip file as the .jar file, in fact. They don't need to download the jar file, just click a link or a button to RUN it. Again, sorry if I was being unclear. I'll try to remove "website" and replace it with "webpage", maybe that'll clear a bit of the confusion.
Dec 4, 2012 at 20:40 comment added Markus A. @NickHartley If the jar file is already located on the user's computer, then you need to indeed find a way to get the location of it. You could, for example, prompt the user for it. But webstart is more meant for keeping the jar and jnlp files on the server along with your website. So, I would place it into a folder on in your webpage directory on the server and link there. Then the browser will download the jar to the user as needed.
Dec 4, 2012 at 20:36 comment added anon Again, thanks a lot. So all I would need to do is determine the path of the .jar? And if so, can I do it like I do in Java? That is, String path = System.getProperty('user.dir'); or something along the lines of that. Also, do you know if it would be possible to call something that is saved as a .jar file?
Dec 4, 2012 at 18:34 comment added Markus A. It looks like all you need to do is to place a link: <a href=http://www.MySite.com/app.jnlp>Launch the application</a>. But you can get much more fancy than that to make sure all required plugins/JREs/etc. are installed. If the link is all you need, you can open it automatically from JavaScript with something along the lines of window.location.href="http://www.MySite.com/app.jnlp"...
Dec 4, 2012 at 18:29 comment added Markus A. Phew.... I haven't actually used it myself yet. I will be soon, that's why I read up on it already... But maybe this helps: docs.oracle.com/javase/6/docs/technotes/guides/javaws/… (especially chapter 2 and 3) ?
Dec 4, 2012 at 18:20 comment added anon Would you mind providing an example though? I can't figure out where to put this code. It worked by itself, but I need to know where to put it in on a real webpage. Sorry :P
Dec 4, 2012 at 18:19 vote accept Community Bot
Dec 4, 2012 at 18:05 vote accept Community Bot
Dec 4, 2012 at 18:19
Dec 4, 2012 at 17:55 history edited Markus A. CC BY-SA 3.0
added 1 characters in body
Dec 4, 2012 at 17:51 comment added anon Wait, this seems perfect. Disregard my earlier comment, I hadn't scrolled down to this one yet.
Dec 4, 2012 at 15:53 history answered Markus A. CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /