From fc8a16405c52ca404cb913dc867845b54262b581 Mon Sep 17 00:00:00 2001 From: michelou Date: Mon, 17 Oct 2005 19:05:21 +0000 Subject: *** empty log message *** --- config/izpack/registry/.cvsignore | 2 + config/izpack/registry/Makefile | 65 ++++++++++++++ config/izpack/registry/bin/ICE_JNIRegistry.dll | Bin 0 -> 65536 bytes config/izpack/registry/bin/readme.txt | 50 +++++++++++ config/izpack/registry/src/MANIFEST.MF | 3 + config/izpack/registry/src/Main.java | 120 +++++++++++++++++++++++++ 6 files changed, 240 insertions(+) create mode 100644 config/izpack/registry/.cvsignore create mode 100644 config/izpack/registry/Makefile create mode 100644 config/izpack/registry/bin/ICE_JNIRegistry.dll create mode 100644 config/izpack/registry/bin/readme.txt create mode 100644 config/izpack/registry/src/MANIFEST.MF create mode 100644 config/izpack/registry/src/Main.java diff --git a/config/izpack/registry/.cvsignore b/config/izpack/registry/.cvsignore new file mode 100644 index 0000000000..57f684ee18 --- /dev/null +++ b/config/izpack/registry/.cvsignore @@ -0,0 +1,2 @@ +classes + diff --git a/config/izpack/registry/Makefile b/config/izpack/registry/Makefile new file mode 100644 index 0000000000..340f5ed939 --- /dev/null +++ b/config/izpack/registry/Makefile @@ -0,0 +1,65 @@ +############################################################################## + +BINDIR = bin +SOURCEDIR = src +OUTPUTDIR = classes + +JAVA_FILES = Main +JAVA_SOURCES += $(JAVA_FILES:%=$(SOURCEDIR)/%.java) + +APP_MAIN = Main +APP_ARGS = + +CYGWIN = $(filter CYGWIN%,$(shell uname)) +CYGPATH = $(if $(CYGWIN),`cygpath -wp $(1)`,$(1)) + +REGISTRY_HOME ?= /home/linuxsoft/apps/registry +REGISTRY_JARFILE = $(REGISTRY_HOME)/bin/registry.jar + +JAVA_HOME = /home/linuxsoft/apps/java-1.4 + +JAVAC ?= $(JAVA_HOME)/bin/javac +JAVAC_OPTIONS += -classpath $(call CYGPATH,$(REGISTRY_JARFILE)) +JAVAC_OPTIONS += -d $(OUTPUTDIR) + +JAR ?= $(JAVA_HOME)/bin/jar +JAR_OPTIONS += +SETENV_JARFILE = $(BINDIR)/setenv.jar + +JAVA += $(JAVA_HOME)/bin/java +JAVA_OPTIONS += -cp $(call CYGPATH,$(REGISTRY_JARFILE):$(OUTPUTDIR)) +JAVA_OPTIONS += -Djava.library.path=$(call CYGPATH,$(REGISTRY_HOME)/bin) + +############################################################################## + +MKDIR = mkdir -p +RM = rm -f +TOUCH = touch + +############################################################################## +# Commands + +all: .latest-jc + +clean: + @$(RM) -r $(OUTPUTDIR) .latest-* + +run: all + @$(JAVA) $(JAVA_OPTIONS) $(APP_MAIN) $(APP_ARGS) + +.PHONY: all +.PHONY: clean +.PHONY: run + +############################################################################## +# Rules + +.latest-jc: $(JAVA_SOURCES) + @[ -d "$(OUTPUTDIR)" ] || $(MKDIR) $(OUTPUTDIR) + $(JAVAC) $(JAVAC_OPTIONS) $< + $(JAR) cfm $(SETENV_JARFILE) \ + src/MANIFEST.MF -C $(OUTPUTDIR) \ + $(APP_MAIN).class + @$(TOUCH) $@ + +############################################################################## diff --git a/config/izpack/registry/bin/ICE_JNIRegistry.dll b/config/izpack/registry/bin/ICE_JNIRegistry.dll new file mode 100644 index 0000000000..5463a70a40 Binary files /dev/null and b/config/izpack/registry/bin/ICE_JNIRegistry.dll differ diff --git a/config/izpack/registry/bin/readme.txt b/config/izpack/registry/bin/readme.txt new file mode 100644 index 0000000000..19b8731936 --- /dev/null +++ b/config/izpack/registry/bin/readme.txt @@ -0,0 +1,50 @@ + + Windows Registry API Native Interface + +*Release 3.1.3, September 11, 2003* + +The com.ice.jni.registry package is a Java native interface for the +Windows Registry API. This allows Java program to access, modify, and +export Windows Registry resources. + +The com.ice.jni.registry package has been placed into the public domain. +Thus, you have absolutely no licensing issues to consider. You may do +anything you wish with the code. Of course, I always appreciate it when +you properly credit my work. + +The package will work only with Java 1.1 and greater, and uses the +Javasoft native interface, not the Netscape interface. The package also +includes a DLL that implements the interface. The package has been used +with JDK1.2, and JDK1.3, JDK1.4, as well as JDK1.1.8. + +The package includes the pre-built DLL (debug and release), source code +(both the Java and the DLL's C code), as well as the compiled Java classes. + +The original release was posted on November 17, 1997. The current +release is 3.1.3, which was posted on September 11, 2003. + +Email me if you have questions. + + + View The Source Code + +You can now directly view the JNIRegistry source code + and +source code documentation + +online via the Giant Java Tree. + + + Downloads + +Download the WinZip-ed package. (FTP) + + +Download the WinZip-ed package. (HTTP) + + + +------------------------------------------------------------------------ +* All contents are copyrighted (c) by ICE Engineering, Inc. * +http://www.trustice.com/ --- http://www.icetoo.com/ + diff --git a/config/izpack/registry/src/MANIFEST.MF b/config/izpack/registry/src/MANIFEST.MF new file mode 100644 index 0000000000..10e8c9b34f --- /dev/null +++ b/config/izpack/registry/src/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Created-By: 1.4.2_09 (Sun Microsystems Inc.) +Main-Class: Main diff --git a/config/izpack/registry/src/Main.java b/config/izpack/registry/src/Main.java new file mode 100644 index 0000000000..6f5ee96bfd --- /dev/null +++ b/config/izpack/registry/src/Main.java @@ -0,0 +1,120 @@ +// File : Main.java +// Project : Scala +// Author(s) : Stephane Micheloud (mics) +// Environment: JNI Registry 3.1.3, Sun JDK 1.4.2_09 +// Version : 01 +// Created : 25.09.2005/mics +// Modified : - + + +import com.ice.jni.registry.NoSuchKeyException; +import com.ice.jni.registry.NoSuchValueException; +import com.ice.jni.registry.Registry; +import com.ice.jni.registry.RegistryException; +import com.ice.jni.registry.RegistryKey; +import com.ice.jni.registry.RegistryValue; +import com.ice.jni.registry.RegMultiStringValue; +import com.ice.jni.registry.RegStringValue; + +public class Main { + + private static final String PATH = "PATH"; + private static final String SCALA_HOME = "SCALA_HOME"; + private static final String SCALA_BIN = "%" + SCALA_HOME + "%\\bin"; + + private static void updateRegistry(String homePath, String fullName) throws RegistryException { + // HKEY_CURRENT_USER\Environment + RegistryKey envKey = Registry.openSubkey( + Registry.HKEY_CURRENT_USER, + "Environment", + RegistryKey.ACCESS_ALL); + if (homePath != null) { + // set home directory + RegStringValue data = new RegStringValue(envKey, SCALA_HOME, homePath); + envKey.setValue(data); + // update user path + String path = envKey.getStringValue(PATH); + if (path.indexOf(SCALA_BIN) < 0) { + int inx = path.lastIndexOf(";"); + StringBuffer buf = new StringBuffer(path); + if (0 < inx && inx < path.length()-1) + buf.append(";"); + buf.append(SCALA_BIN); + data = new RegStringValue(envKey, PATH, buf.toString()); + envKey.setValue(data); + } + } + else { // uninstall + // remove home directory + try { + envKey.deleteValue(SCALA_HOME); + } + catch (NoSuchValueException e) { + // do nothing + } + String path = envKey.getStringValue(PATH); + int inx1 = path.indexOf(SCALA_BIN); + if (inx1 >= 0) { + int inx2 = path.indexOf(";", inx1); + StringBuffer buf = new StringBuffer(path.substring(0, inx1)); + if (inx2 >= 0) + buf.append(path.substring(inx2)); + RegStringValue data = new RegStringValue(envKey, PATH, buf.toString()); + envKey.setValue(data); + } + } + + // HKEY_CURRENT_USER\Software + RegistryKey softwareKey = Registry.openSubkey( + Registry.HKEY_CURRENT_USER, + "Software", + RegistryKey.ACCESS_WRITE); + if (homePath != null) { + RegistryKey productKey = softwareKey.createSubKey( + fullName, + "java.lang.String", + RegistryKey.ACCESS_WRITE); + RegStringValue data = new RegStringValue(productKey, "Location", homePath); + productKey.setValue(data); + } + else { // uninstall + try { + softwareKey.deleteSubKey(fullName); + String name = fullName; + int inx = name.lastIndexOf("\\"); + while (inx != -1) { + String parentName = name.substring(0, inx); + RegistryKey key = softwareKey.openSubKey(parentName, RegistryKey.ACCESS_READ); + int n = key.getNumberSubkeys(); + if (n == 0) softwareKey.deleteSubKey(parentName); + name = parentName; + inx = name.lastIndexOf("\\"); + } + } + catch (NoSuchKeyException e) { + // do nothing + } + } + } + + public static void main(String[] args) { + int argc = args.length; + if (argc != 1 && argc != 2) { + System.out.println("Usage: java Main [ ]\n"); + System.out.println("\tversion number (e.g. 1.4.0.1)"); + System.out.println("\tinstall path (e.g. c:\\\\Program Files\\\\Scala)"); + System.out.println(); + System.exit((argc > 0) ? 1 : 0); + } + String homePath = (argc == 2) ? args[1] : null; // e.g. "C:\\Program Files\\Scala" + String fullName = "EPFL\\Scala\\" + args[0]; // e.g. "EPFL\\Scala\\1.4.0.1" + try { + updateRegistry(homePath, fullName); + } + catch (RegistryException e) { + System.out.println(e.getMessage()); + System.exit(1); + } + } + +} -- cgit v1.2.3