Background
I stumbled upon an old applet of mine which is extremely outdated (parts of it from 2001), and I would really like to bring it back from the dead! The applet should open a file in its native application (among other things), but this doesn’t work on the latest Windows versions (including Windows 7), it works well on Windows XP.
try {
if (Class.forName("com.ms.security.PolicyEngine") != null) {
PolicyEngine.assertPermission(PermissionID.EXEC);
PolicyEngine.assertPermission(PermissionID.FILEIO);
PolicyEngine.assertPermission(PermissionID.NETIO);
PolicyEngine.assertPermission(PermissionID.UI);
PolicyEngine.assertPermission(PermissionID.USERFILEIO);
PolicyEngine.assertPermission(PermissionID.CLIENTSTORE);
}
else {
}
} catch (Throwable e) {
}
Problem/Solution
I am pretty sure that the above code has something to do with it. Is it as easy as just removing this code completely and then re-signing the applet? Or do I need to re-implement it with the java.security package instead before signing it? If I need to re-implement it with java.security, is it enough just using something similar:
try {
if (Class.forName("java.security.Policy") != null) {
final Permissions permissions = new Permissions();
permissions.add( new java.security.AllPermission());
}
else {
}
} catch (Throwable e) {
}
What do I need to make it work on Windows 7?
The applet is using Java version 1.5.0 (J2SE 5.0).
.
Cheers.
UPDATE
Here is the code that works in Windows XP, but does not seem to execute in Windows 7.
String command = '"' + sDir + sFileName + '"';
Runtime myRuntime = Runtime.getRuntime();
try {
myRuntime.exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + command);
gGfx.setStatusText("File opened.");
gGfx.drawStatusBar(1);
} catch (IOException e) {
System.out.println("Error " + e.getMessage());
}
That is the solution here.