home *** CD-ROM | disk | FTP | other *** search
- !!Script
- // Copyright ⌐ 1997-1998 - Modelworks Software
- // @Modified build 230 cm19981101 - created function DefineJDKDirectory() out of SetNewDirectory()
- // @Modified build 263 cm19990204 - added instructions for new users
- // @Modified build 317 cm19990805 - see below
- // @Modified build 422 cm20000923 - see below
-
- /**
- @Tool: JDK~displays a open folder dialog to let you select
- your JDK (Java Development Kit) directory.
- @Image: Open Folder Dialog showing a JDK directory@select_JDK_Directory.gif
- @Tip: Because some JDK tools do not process classpaths correctly if the classpath contains a
- space, you should avoid using spaces in folder names that contain Java source or class file
- names.
- @EndTip:
- @EndTool:
- @Summary: JDK~sets the path to your JDK directory
- */
-
- var gOutput = getOutput();
- var gHelpers = getMapFile("ApplicationHelpers");
- var gOptions = getMapFile("JDKToolsStandardOptions");
-
- function DoCommand()
- {
- var jdk_bin_directory = gHelpers.lookup("jdk-bin_directory");
- if (jdk_bin_directory == null || !jdk_bin_directory.exists)
- {
- InitilizeJDKDirectory(); //cm20000923
- }
-
- jdk_bin_directory = gHelpers.lookup("jdk-bin_directory");
- if (jdk_bin_directory && jdk_bin_directory.exists)
- {
- var compilePath = newFile(jdk_bin_directory.path + "\\javac.exe");
- if (compilePath.exists)
- {
- var to = jdk_bin_directory.path.length - 4;
- var jdk_directory_path = jdk_bin_directory.path.substring(0, to);
- if (confirm("Your current JDK directory is: " + jdk_directory_path +
- ". Do you want to change to a new directory?"))
- {
- SetNewDirectory(jdk_directory_path);
- }
- return; // cm19990805
- }
- }
-
- if (confirm("If you have not downloaded JDK from Sun Microsystems, "
- + "\nyou will need to do so before you continue. \n"
- + "Select no to get instructions, select yes to continue."))
- {
- SetNewDirectory("C:\\");
- }
- else
- {
- var outputEditor = gOutput.getEditor();
- var startLine = outputEditor.getLineCount();
-
- gOutput.writeLine("\nTo download the current JDK and documentation go to: ");
- gOutput.writeLine("http://www.javasoft.com/products/jdk/index.html");
-
- gOutput.writeLine("");
- gOutput.writeLine("We recommend that you install JDK in a top level folder, such as C:\\JDK.1.2,");
- gOutput.writeLine("without any spaces in the folder name, so that the visual debugger will work");
- gOutput.writeLine("(Sun's JDK debugger will not work if there is a space in a classpath).");
-
- gOutput.writeLine("");
- gOutput.writeLine("After downloading and installing JDK you can then restart " + Application.name + ".");
- gOutput.writeLine("If you installed a recent version of JDK (at least version 1.1.7) then ");
- gOutput.writeLine(Application.name + " will automatically locate your JDK during startup if you ");
- gOutput.writeLine("have not already selected a JDK directory.");
-
- gOutput.writeLine("");
- gOutput.writeLine("You may also want to see \"Documents/Ide/Useful Links\" for other useful");
- gOutput.writeLine("internet shortcuts.");
-
- outputEditor.scrollTo(startLine);
- }
- }
-
- function SetNewDirectory(oldPath)
- {
- gOutput.clear();
-
- var directory = chooseDirectory("Locate your Java JDK directory", oldPath, "");
- if (directory)
- {
- var test = newFile(directory + "\\java.exe");
- if (test.exists) // Remove "\\bin"
- {
- var to = directory.length - 4;
- directory = directory.substring(0, to);
- }
-
- if (DefineJDKDirectory(directory))
- {
- gOutput.writeLine("Reminder: be sure to change your standard and custom classpaths if required.");
- }
- }
- }
-
- function DefineJDKDirectory(directory)
- {
- var jdk_directoryFile = newFile(directory);
-
- var jdk_bin_directory = newFile(directory + "\\bin");
- var compilePath = newFile(directory + "\\bin\\javac.exe");
- if (jdk_bin_directory.exists && compilePath.exists)
- {
- gHelpers.add("jdk-directory", jdk_directoryFile);
- gHelpers.add("jdk-bin_directory", jdk_bin_directory);
-
- var tool = newTool();
- var pathEnvironment = getGlobal("EnvironmentPath");
- tool.setEnvironmentVariable("Path", jdk_bin_directory.path + ";" + pathEnvironment);
-
- // Java compiler
- var compilePath_g = newFile(directory + "\\bin\\javac_g.exe");
- gHelpers.add("jdk-compiler_release", compilePath);
- if (compilePath_g.exists)
- {
- gHelpers.add("jdk-compiler_debug", compilePath_g);
- gHelpers.add("jdk-compiler", compilePath_g);
- }
- else
- {
- gHelpers.add("jdk-compiler_debug", compilePath);
- gHelpers.add("jdk-compiler", compilePath);
- }
-
- // Appletviewer
- var appletviewerPath = newFile(directory + "\\bin\\appletviewer.exe");
- var appletviewerPath_g = newFile(directory + "\\bin\\appletviewer_g.exe");
-
- gHelpers.add("jdk-appletviewer_release", appletviewerPath);
- if (appletviewerPath_g.exists)
- {
- gHelpers.add("jdk-appletviewer_debug", appletviewerPath_g);
- gHelpers.add("jdk-appletviewer", appletviewerPath_g);
- }
- else
- {
- gHelpers.add("jdk-appletviewer_debug", appletviewerPath);
- gHelpers.add("jdk-appletviewer", appletviewerPath);
- }
-
- // Application runtime
- var runApplicationPath = newFile(directory + "\\bin\\java.exe");
- var runApplicationPath_g = newFile(directory + "\\bin\\java_g.exe");
-
- gHelpers.add("jdk-runapplication_release", runApplicationPath);
- if (runApplicationPath_g.exists)
- {
- gHelpers.add("jdk-runapplication_debug", runApplicationPath_g);
- gHelpers.add("jdk-runapplication", runApplicationPath_g);
- }
- else
- {
- gHelpers.add("jdk-runapplication_debug", runApplicationPath);
- gHelpers.add("jdk-runapplication", runApplicationPath);
- }
-
- var runApplicationPathWindow = newFile(directory + "\\bin\\javaw.exe");
- var runApplicationPathWindow_g = newFile(directory + "\\bin\\javaw_g.exe");
-
- gHelpers.add("jdk-runapplicationwindow_release", runApplicationPathWindow);
- if (runApplicationPathWindow_g.exists)
- {
- gHelpers.add("jdk-runapplicationwindow_debug", runApplicationPathWindow_g);
- gHelpers.add("jdk-runapplicationwindow", runApplicationPathWindow_g);
- }
- else
- {
- gHelpers.add("jdk-runapplicationwindow_debug", runApplicationPathWindow);
- gHelpers.add("jdk-runapplicationwindow", runApplicationPathWindow);
- }
-
- // Debugger
- var debuggerPath = newFile(directory + "\\bin\\jdb.exe");
- gHelpers.add("jdk-debugger", debuggerPath);
-
- // Add Classes.zip if it exists
- var classesPath = newFile(directory + "\\lib\\classes.zip");
- if (classesPath && classesPath.exists)
- {
- gHelpers.add("jdk-classes.zip", classesPath);
- }
- else
- {
- gHelpers.remove("jdk-classes.zip");
- }
-
- // Generate C bindings
- var javahPath = newFile(directory + "\\bin\\javah.exe");
- gHelpers.add("jdk-javah", javahPath);
-
- // Update the options
-
- var buildmode = gOptions.lookup("jdk-buildmode", "");
- if (buildmode == "") // Define the initial options
- {
- gOptions.setValue("jdk-buildmode", "release");
- gOptions.setValue("jdk-build", "JDK Release Build");
- gOptions.lookup("runInWindow", true);
- //alert("JDK Release Build Configuration Set");
- }
-
- var jdkOptions = getScriptObject("\\Library\\jdkOptions");
- jdkOptions.UpdateOptions();
-
- gOutput.writeLine("JDK directory set to: \"" + directory + "\"");
- if (directory.indexOf(" ") != -1)
- {
- gOutput.writeLine("Warning: some JDK tools may not work correctly with a space in your JDK path.");
- }
-
- return true;
- }
- else
- {
- gOutput.writeLine("WARNING: The directory, \"" + directory +
- "\" does not appear to be a valid JDK directory");
- gOutput.writeLine("A valid JDK directory contains a bin folder containing Sun's Java tools (e.g., javac.exe)");
- }
-
- return false;
- }
-
- function InitilizeJDKDirectory() //cm19981101
- {
- var key = "SOFTWARE\\JavaSoft\\Java Development Kit";
- var currentVersion = Application.getRegistryValue("HKEY_LOCAL_MACHINE",
- key ,"CurrentVersion");
- if (currentVersion && currentVersion != "")
- {
- key += "\\" + currentVersion;
- var javaHome = Application.getRegistryValue("HKEY_LOCAL_MACHINE",
- key, "JavaHome");
-
- if (javaHome && javaHome != "")
- {
- DefineJDKDirectory(javaHome);
- }
- }
- }
-
-
- !!/Script
-