aspose file tools*
The moose likes Applets and the fly likes Java Applets and file execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Java Applets and file execution" Watch "Java Applets and file execution" New topic
Author

Java Applets and file execution

Lance Walker
Greenhorn

Joined: Mar 09, 2009
Posts: 23
I'm creating a front end java applet for my website in which the user will interact with to create a theme for their windows computer. I have many simple aspects completed however there are a few things I would like to implement that I cannot seem to get working.

The first, and most important, is that I would like to download and execute a file when the user presses a button (for instance, if they wish to install a screen saver, it will download the .scr and start the user installation window). I have been told this is possible in a java applet but can't seem to find any resources describing how to carry it out.

Second, I want to be able to pass the name of a selected keyword into the applet so that it will download the appropriate file. For example, using the same hypothetical situation as above, the user searches for bunnies wallpapers, it will download a bunny wallpaper from a list of choices.

Finally, I was wondering if I would have sufficient privileges to open local windows control panel applets (.cpl) through a java applet. I haven't tried to implement this yet, but I figured while I'm here posting, someone might happen to know the answer. Basically, what I want to do it use System.run("rundll32.exe shell32.dll,Control_RunDLL themes.cpl") to pop up the user's theme window.

Thanks in advance for any help! I'll be checking back every few minutes to provide more details as is necessary.

-Lance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
The first and the third question sound pretty similar (unless I'm missing something). You'll need to jump out of the applet security sandbox to use Runtime.exec, but then it's possible. See HowCanAnAppletReadFilesOnTheLocalFileSystem for a description of the two principal ways to do that; I think applet signing would be the easier solution in your situation.

As to the second question, what exactly do you mean by "pass the name ... into the applet"? If the user should type it in you can use a JTextField; if she should choose it from a list, there's JList.


Ping & DNS - my free Android networking tools app
Lance Walker
Greenhorn

Joined: Mar 09, 2009
Posts: 23
Thanks for the reply! I'm working on signing my applet as we speak. For my second question, what I mean is the user is browsing a page with a bunch of download links. When the user clicks on one of the download links, it takes them to the page with the applet and then "passes" the keyword of what they want to download to the java applet. By doing this, the applet will be able to fetch the correct download from the server. Any ideas how I could do this?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42282
    
  64
With a <param> tag inside the applet tag you can pass any data that can be expressed as string to an applet; see http://java.sun.com/docs/books/tutorial/deployment/applet/html.html for details.
Lance Walker
Greenhorn

Joined: Mar 09, 2009
Posts: 23
Thanks for your help. Things are looking better now
 
Consider Paul's rocket mass heater.
 
subject: Java Applets and file execution