NetBeans configuration » History » Version 1
Herve Ballans, 12/07/2012 11:11
| 1 | 1 | Herve Ballans | h1. Environnement |
|---|---|---|---|
| 2 | 1 | Herve Ballans | |
| 3 | 1 | Herve Ballans | h2. Configuration de NetBeans pour développer des extensions SITools2 |
| 4 | 1 | Herve Ballans | |
| 5 | 1 | Herve Ballans | * Installer SITools2 par izpack |
| 6 | 1 | Herve Ballans | * Changer le fichier sitools.properties en remplacant "../fr.cnes.sitools.core" par le chemin absolu du package fr.cnes.sitools.core |
| 7 | 1 | Herve Ballans | * Créer un projet Netbeans pour les extensions |
| 8 | 1 | Herve Ballans | * Importer les jars de sitools2 (voir la doc dev bientot dispo) |
| 9 | 1 | Herve Ballans | * Ajouter ce package : |
| 10 | 1 | Herve Ballans | |
| 11 | 1 | Herve Ballans | <pre><code class="java"> |
| 12 | 1 | Herve Ballans | package run; |
| 13 | 1 | Herve Ballans | |
| 14 | 1 | Herve Ballans | /** |
| 15 | 1 | Herve Ballans | * Special Class to be able to run SITools2 from an extension project |
| 16 | 1 | Herve Ballans | * sitools.properties must be modified : replace ../fr.cnes.sitools.core by the absolute path |
| 17 | 1 | Herve Ballans | * @author Jean-Christophe Malapert |
| 18 | 1 | Herve Ballans | */ |
| 19 | 1 | Herve Ballans | import java.lang.reflect.InvocationTargetException; |
| 20 | 1 | Herve Ballans | import java.lang.reflect.Method; |
| 21 | 1 | Herve Ballans | |
| 22 | 1 | Herve Ballans | public class Invoker { |
| 23 | 1 | Herve Ballans | |
| 24 | 1 | Herve Ballans | public final static String SITOOLS_MAIN_CLASS = "fr.cnes.sitools.server.Starter"; |
| 25 | 1 | Herve Ballans | |
| 26 | 1 | Herve Ballans | public static void main(String[] args) { |
| 27 | 1 | Herve Ballans | String[] args1 = new String[1]; |
| 28 | 1 | Herve Ballans | |
| 29 | 1 | Herve Ballans | args1[0] = SITOOLS_MAIN_CLASS; |
| 30 | 1 | Herve Ballans | args = args1; |
| 31 | 1 | Herve Ballans | if (args.length != 1) { |
| 32 | 1 | Herve Ballans | System.err.println("Sitools Main class is not set"); |
| 33 | 1 | Herve Ballans | System.exit(1); |
| 34 | 1 | Herve Ballans | } |
| 35 | 1 | Herve Ballans | |
| 36 | 1 | Herve Ballans | Class[] argTypes = new Class[1]; |
| 37 | 1 | Herve Ballans | argTypes[0] = String[].class; |
| 38 | 1 | Herve Ballans | try { |
| 39 | 1 | Herve Ballans | Method mainMethod = Class.forName(args[0]).getDeclaredMethod("main", argTypes); |
| 40 | 1 | Herve Ballans | Object[] argListForInvokedMain = new Object[1]; |
| 41 | 1 | Herve Ballans | argListForInvokedMain[0] = new String[0]; |
| 42 | 1 | Herve Ballans | mainMethod.invoke(null,argListForInvokedMain); |
| 43 | 1 | Herve Ballans | } catch (ClassNotFoundException ex) { |
| 44 | 1 | Herve Ballans | System.err.println("Class " + args[0] + "not found in classpath."); |
| 45 | 1 | Herve Ballans | } catch (NoSuchMethodException ex) { |
| 46 | 1 | Herve Ballans | System.err.println("Class " + args[0] + "does not define public static void main(String[])"); |
| 47 | 1 | Herve Ballans | } catch (InvocationTargetException ex) { |
| 48 | 1 | Herve Ballans | System.err.println("Exception while executing " + args[0] + ":" + ex.getTargetException()); |
| 49 | 1 | Herve Ballans | } catch (IllegalAccessException ex) { |
| 50 | 1 | Herve Ballans | System.err.println("main(String[]) in class " + args[0] + " is not public"); |
| 51 | 1 | Herve Ballans | } |
| 52 | 1 | Herve Ballans | } |
| 53 | 1 | Herve Ballans | } |
| 54 | 1 | Herve Ballans | </code></pre> |
| 55 | 1 | Herve Ballans | |
| 56 | 1 | Herve Ballans | * Faire run ou debug du projet |