diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index a40e0c11c..9e6e7e967 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -162,7 +162,7 @@ public class Base { // because the platform has to be inited properly first. // Make sure a full JDK is installed - initRequirements(); +// initRequirements(); // run static initialization that grabs all the prefs Preferences.init(null); diff --git a/app/src/processing/app/windows/Platform.java b/app/src/processing/app/windows/Platform.java index ddbf013c1..d0e9d135e 100644 --- a/app/src/processing/app/windows/Platform.java +++ b/app/src/processing/app/windows/Platform.java @@ -22,6 +22,7 @@ package processing.app.windows; +import java.awt.EventQueue; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.HashMap; @@ -57,6 +58,26 @@ public class Platform extends processing.app.Platform { checkAssociations(); //checkQuickTime(); checkPath(); + + //findJDK(); + EventQueue.invokeLater(new Runnable() { + public void run() { + findJDK(); + } + }); + } + + + protected void findJDK() { + try { + String currentVersion = + Registry.getStringValue(REGISTRY_ROOT_KEY.LOCAL_MACHINE, + "SOFTWARE", + "JavaSoft\\Java Development Kit\\CurrentVersion"); + System.out.println("current version is " + currentVersion); + } catch (UnsupportedEncodingException uee) { + uee.printStackTrace(); + } } @@ -199,22 +220,22 @@ public class Platform extends processing.app.Platform { // "\\Explorer\\Shell Folders"; //String appDataPath = // Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER, keyPath, "AppData"); - + // Fix for Issue 410 // Java 1.6 doesn't provide a good workaround (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127) // Using JNA and SHGetFolderPath instead. - + char[] pszPath = new char[Shell32.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful int hResult = Shell32.INSTANCE.SHGetFolderPath(null, Shell32.CSIDL_APPDATA, null, Shell32.SHGFP_TYPE_CURRENT, pszPath); - - if (Shell32.S_OK != hResult){ + + if (Shell32.S_OK != hResult){ throw new Exception("Problem city, population your computer"); } String appDataPath = new String(pszPath); int len = appDataPath.indexOf("\0"); appDataPath = appDataPath.substring(0, len); - + // DEBUG //throw new Exception("win: " + appDataPath); return new File(appDataPath, "Processing"); @@ -243,21 +264,21 @@ public class Platform extends processing.app.Platform { // "\\Explorer\\Shell Folders"; //String personalPath = // Registry.getStringValue(REGISTRY_ROOT_KEY.CURRENT_USER, keyPath, "Personal"); - - // "The "Shell Folders" key exists solely to permit four programs written + + // "The "Shell Folders" key exists solely to permit four programs written // in 1994 to continue running on the RTM version of Windows 95." -- Raymond Chen, MSDN char[] pszPath = new char[Shell32.MAX_PATH]; // this will be contain the path if SHGetFolderPath is successful int hResult = Shell32.INSTANCE.SHGetFolderPath(null, Shell32.CSIDL_PERSONAL, null, Shell32.SHGFP_TYPE_CURRENT, pszPath); - - if (Shell32.S_OK != hResult){ + + if (Shell32.S_OK != hResult){ throw new Exception("Problem city, population your computer"); } String personalPath = new String(pszPath); int len = personalPath.indexOf("\0"); personalPath = personalPath.substring(0, len); - + // DEBUG //throw new Exception("win: " + personalPath); return new File(personalPath, "Processing"); @@ -328,7 +349,7 @@ public class Platform extends processing.app.Platform { public int _putenv(String name); } - + public void setenv(String variable, String value) { //WinLibC clib = WinLibC.INSTANCE; clib._putenv(variable + "=" + value); @@ -346,47 +367,47 @@ public class Platform extends processing.app.Platform { //return 0; return clib._putenv(variable + "="); } - + // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - + // JNA code for using SHGetFolderPath to fix Issue 410 // Based on answer provided by McDowell at // http://stackoverflow.com/questions/585534/ // what-is-the-best-way-to-find-the-users-home-directory-in-java/586917#586917 - + private static Map OPTIONS = new HashMap(); - + static{ OPTIONS.put(Library.OPTION_TYPE_MAPPER, W32APITypeMapper.UNICODE); OPTIONS.put(Library.OPTION_FUNCTION_MAPPER, W32APIFunctionMapper.UNICODE); } - + static class HANDLE extends PointerType implements NativeMapped{} - + static class HWND extends HANDLE {} - + public interface Shell32 extends Library{ - + public static final int MAX_PATH = 260; public static final int SHGFP_TYPE_CURRENT = 0; public static final int SHGFP_TYPE_DEFAULT = 1; public static final int S_OK = 0; - + // KNOWNFOLDERIDs are preferred to CSDIL values // but Windows XP only supports CSDIL so thats what we have to use public static final int CSIDL_APPDATA = 0x001a; // "Application Data" public static final int CSIDL_PERSONAL = 0x0005; // "My Documents" - + static Shell32 INSTANCE = (Shell32) Native.loadLibrary("shell32", Shell32.class, OPTIONS); - + /** * see http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx - * + * * HRESULT SHGetFolderPath( HWND hwndOwner, int nFolder, HANDLE hToken, * DWORD dwFlags, LPTSTR pszPath); */ public int SHGetFolderPath(HWND hwndOwner, int nFolder, HANDLE hToken, int dwFlags, char[] pszPath); } - + } diff --git a/todo.txt b/todo.txt index 281984296..74c203fb6 100644 --- a/todo.txt +++ b/todo.txt @@ -16,6 +16,12 @@ o no crash when double-clicking a sketch and loading it (?) X http://code.google.com/p/processing/issues/detail?id=176 X also move back to using non-custom for 2.0 when we can drop QT support +_ move initRequirements check for JVM to Runner + +_ grab tools.jar from reg keys? +_ don't mess with reg keys until the app is loaded +_ NPE causes trouble sometimes + _ revisions.txt should have Windows line endings _ change in SVN to be platform specific _ add 64-bit Linux version to the next download