1 | import java.awt.BorderLayout; |
---|
2 | import java.awt.Color; |
---|
3 | import java.awt.Frame; |
---|
4 | import java.awt.Label; |
---|
5 | import java.awt.Window; |
---|
6 | import java.lang.reflect.Method; |
---|
7 | import java.net.MalformedURLException; |
---|
8 | import java.net.URL; |
---|
9 | import java.net.URLClassLoader; |
---|
10 | |
---|
11 | |
---|
12 | |
---|
13 | /** |
---|
14 | * remote Load jeti |
---|
15 | * use it to load jeti from network |
---|
16 | * or on a multi user system |
---|
17 | * (only config files and logs are stored localy) |
---|
18 | */ |
---|
19 | public class IM extends Window |
---|
20 | { |
---|
21 | private Label from; |
---|
22 | |
---|
23 | public IM(Frame frame) |
---|
24 | { |
---|
25 | super(frame); |
---|
26 | Label label = new Label("Jeti is Loading..."); |
---|
27 | label.setFont(new java.awt.Font("Serif", 1, 40)); |
---|
28 | label.setBackground(new Color(150,150,255)); |
---|
29 | add(label,BorderLayout.CENTER); |
---|
30 | from = new Label("Loading"); |
---|
31 | from.setBackground(new Color(255,255,150)); |
---|
32 | add(from,BorderLayout.SOUTH); |
---|
33 | pack(); |
---|
34 | setLocationRelativeTo(null); |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | public static void main(String[] args) |
---|
39 | { |
---|
40 | String path = System.getProperty("user.dir"); |
---|
41 | path = path.replace('\\','/'); |
---|
42 | path = "file:/" + path + "/"; |
---|
43 | System.out.println(path); |
---|
44 | // try |
---|
45 | // { |
---|
46 | // //System.out.println(args[0]); |
---|
47 | // // |
---|
48 | // System.out.println(new File(".").toURL());// getCanonicalPath()); |
---|
49 | // } |
---|
50 | // catch (IOException e1) |
---|
51 | // { |
---|
52 | // // TODO Auto-generated catch block |
---|
53 | // e1.printStackTrace(); |
---|
54 | // } |
---|
55 | //if(true) return; |
---|
56 | Frame frame = new Frame(); |
---|
57 | IM im = new IM(frame); |
---|
58 | im.show(); |
---|
59 | URL url = null; |
---|
60 | URL url2[] = new URL[1]; |
---|
61 | try { |
---|
62 | //url = new URL ("file:/e:/data/java/jeti/"); |
---|
63 | //url = new URL ("file:/z:/data/java/2m/classes/"); |
---|
64 | //url = new URL ("http://192.168.100.2/~eric/"); |
---|
65 | url = new URL(args[0]); |
---|
66 | |
---|
67 | url2[0] = new URL (url + "Jeti.jar"); |
---|
68 | im.from.setText("from: " + url2[0].toString()); |
---|
69 | //url2[0] = url; |
---|
70 | System.out.println(url2[0]); |
---|
71 | } catch (MalformedURLException e) |
---|
72 | { |
---|
73 | im.from.setText(e.getMessage()); |
---|
74 | e.printStackTrace(); |
---|
75 | } |
---|
76 | URLClassLoader loader = new URLClassLoader(url2); |
---|
77 | Class start = null; |
---|
78 | |
---|
79 | // String path = null; |
---|
80 | // URL urlPath =null; |
---|
81 | // urlPath = IM.class.getResource("IM.class"); |
---|
82 | // try{//remove %20 from program files etc |
---|
83 | // path = URLDecoder.decode(urlPath.toString(),"UTF8");//encode if to url? probaly not |
---|
84 | // }catch (Exception e){e.printStackTrace();}//1.2 error + 1.4 |
---|
85 | // path = path.substring(0,path.lastIndexOf("/")+1); |
---|
86 | |
---|
87 | try{ |
---|
88 | start = loader.loadClass("nu.fw.jeti.backend.Start"); |
---|
89 | Method m = start.getMethod("remoteLoad",new Class[]{java.net.URL.class,String.class}); |
---|
90 | m.invoke(null,new Object[]{url,path}); |
---|
91 | }catch(Exception e){e.printStackTrace();} |
---|
92 | im.dispose(); |
---|
93 | frame.dispose(); |
---|
94 | } |
---|
95 | } |
---|
96 | |
---|
97 | /* |
---|
98 | * Overrides for emacs |
---|
99 | * Local variables: |
---|
100 | * tab-width: 4 |
---|
101 | * End: |
---|
102 | */ |
---|