src/Java.st
branchjk_new_structure
changeset 883 b0eecab8d572
parent 878 b972cc489a01
child 889 e20f62a18b13
--- a/src/Java.st	Sat Aug 06 12:16:37 2011 +0000
+++ b/src/Java.st	Sun Aug 07 13:12:31 2011 +0000
@@ -243,13 +243,14 @@
     ] ifFalse:[
         (ClassPath includes:aPath asString) ifFalse:[
             ClassPath add:aPath asString.
+            self addToClassPathInRuntime:aPath.
             FailedToLoadClasses := nil
         ]
     ]
 
     "Created: / 01-08-1997 / 21:10:07 / cg"
     "Modified: / 17-09-1998 / 20:43:55 / cg"
-    "Modified: / 20-12-2010 / 17:37:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 07-08-2011 / 14:06:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 addToClassPathFilesMatching: pattern in: path
@@ -263,11 +264,32 @@
             p := (dir / fname) pathName.
             (ClassPath includes:p) ifFalse:
                 [ClassPath add:p.
+                self addToClassPathInRuntime:p.
                 FailedToLoadClasses := nil]]].
 
     "Created: / 20-12-2010 / 17:26:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+addToClassPathInRuntime:aPath
+
+    | path file url |
+    "Java might not be loaded/or initialized, in this case
+     there is no no need to inform java about new entry in classpath"
+    (Java at:#'java.lang.System') isNil ifTrue:[^self].
+
+    path := Java as_String: aPath asString.        
+    file := (Java at:'java.io.File') new perform: #'<init>(Ljava/lang/String;)V' with: path; yourself.
+    url := file perform: #'toURL()Ljava/net/URL;'.
+            
+    ((Java at:#'java.lang.ClassLoader') 
+        perform: #'getSystemClassLoader()Ljava/lang/ClassLoader;')
+        perform: #'addURL(Ljava/net/URL;)V' with: url.
+
+    "Created: / 01-08-1997 / 21:10:07 / cg"
+    "Modified: / 17-09-1998 / 20:43:55 / cg"
+    "Created: / 07-08-2011 / 14:01:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 addToSourcePath:aPath
     SourceDirectories ifNil:[SourceDirectories := OrderedCollection new].
     (SourceDirectories includes:aPath) ifFalse:[