KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > init > InitUtility


1 /*
2  * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is
3  * subject to license terms.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the Lesser GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  */

20 package org.jdesktop.jdic.init;
21
22 import java.io.File JavaDoc;
23
24 /**
25  * Utility class for JDIC initialization.
26  * @author Paul Huang
27  * @created August 20, 2004
28  */

29 public class InitUtility {
30     static {
31         System.loadLibrary("jdic");
32     }
33     
34     /**
35      * Gets the value of the environment variable.
36      *
37      * @param envVarName The name of the environment variable.
38      * @return The value of the environment variable.
39      */

40     public static native String JavaDoc getEnv(String JavaDoc envVarName);
41     
42     /**
43      * Sets the environment variable.
44      *
45      * @param ennVarName The name of the environment variable.
46      * @param envValue The value to be set.
47      */

48     public static native void setEnv(String JavaDoc envVarName, String JavaDoc envValue);
49     
50     /**
51      * Pre-appends the value to the environment variable.
52      *
53      * @param envVarName environment variable name.
54      * @param appendValue new value to be appended.
55      */

56     public static void preAppendEnv(String JavaDoc envVarName, String JavaDoc appendValue) {
57         String JavaDoc originalValue = getEnv(envVarName);
58         String JavaDoc newValue = appendValue;
59         if (originalValue != null) {
60             newValue = appendValue.concat(File.pathSeparator).concat(originalValue);
61         }
62         setEnv(envVarName, newValue);
63     }
64 }
Popular Tags