KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > jnlplauncher > Main


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 // XXX is this really an appropriate package? Perhaps move to e.g. org.netbeans.jnlplauncher.
21
package org.netbeans.modules.apisupport.jnlplauncher;
22
23 import java.io.File JavaDoc;
24 import java.security.Policy JavaDoc;
25
26 /** The JNLP entry point. Does not do much, in future it can do more
27  * of JNLP related stuff.
28  *
29  * @author Jaroslav Tulach
30  */

31 public class Main extends Object JavaDoc {
32
33     /** Starts NetBeans
34      * @param args the command line arguments
35      * @throws Exception for lots of reasons
36      */

37     public static void main (String JavaDoc args[]) throws Exception JavaDoc {
38         fixPolicy();
39         fixNetBeansUser();
40         org.netbeans.Main.main(args);
41     }
42     
43     /** Fixes value of netbeans.user property.
44      */

45     final static void fixNetBeansUser() {
46         String JavaDoc userDir = System.getProperty("netbeans.user"); // NOI18N
47
if (userDir == null) {
48             return;
49         }
50         final String JavaDoc PREFIX = "${user.home}/"; // NOI18N
51
int uh = userDir.indexOf(PREFIX);
52         if (uh == -1) {
53             return;
54         }
55         String JavaDoc newDir =
56             userDir.substring(0, uh) +
57             System.getProperty("user.home") + // NOI18N
58
File.separator +
59             userDir.substring(uh + PREFIX.length());
60         System.setProperty("netbeans.user", newDir); // NOI18N
61
}
62     
63     /**
64      * Attempt to give the rest of NetBeans all the
65      * permissions. The jars besides the one containing this class
66      * don't have to be signed with this.
67      */

68     final static void fixPolicy() {
69         if (Boolean.getBoolean("netbeans.jnlp.fixPolicy")) { // NOI18N
70
// Grant all the code all persmission
71
Policy.setPolicy(new RuntimePolicy());
72             // Replace the security manager by a fresh copy
73
// that does the delegation to the permissions system
74
// -- just to make sure that there is nothing left
75
// from the JWS
76
System.setSecurityManager(new SecurityManager JavaDoc());
77         }
78     }
79 }
80
Popular Tags