简体   繁体   中英

Setting environment variables in Java Applet

I'm using xuggler api in my applet. And xuggler's wiki says I cannot use it in an applet. But I tried it with 3 computers. And my applet will work if I can add xugglers bin folder to system environment path variable and create a new environment variable XUGGLE_HOME . I have no problem with copying xugglers libraries to target computer. What I would like to do is something like that:

  • Copy xuggler files
  • Set environment variables
  • Run applet
  • Delete xuggler files
  • Delete environment variables

But probably because I'm doing these in applet, environment variable changes won't be effective in that applets runtime. And another problem is how I could change environment variables. Because if I use a .bat file, it has a limit that would make malformations in path variable. And other choices like vbscript and .reg file didn't work.(vbscript gives access denied on some computers and .reg file looks like it works but doesn't work somehow)

So is there anyway to set environment variables prior to running applet?

Thanks

EDIT : Actually I tried a different method now which worked like a charm. Now my applet on website only copies xuggle folders and my main program jar into a temp directory from a zip file. Then applet launches a bat file which was in zip file. Bat file sets (not setx) variables and runs my main jar. Because child process gets parents environment it works. And after that cmd window closed, no change to system. Only if I could hide that cmd window.

Well,that said I still wonder if it's possible to change environment variables in java.

Try the latest Xuggler which now includes the native code in the jar file. I'm not sure if it'll work with applets. If it does, please let us know on the Xuggler support alias.

You could set params for use in your applet if only the applet needs the XUGGLE_HOME path.

<APPLET CODE="your.class" WIDTH=100 HEIGHT=100>
    <PARAM NAME=XUGGLE_HOME VALUE="path">
</APPLET>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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