Results 1 to 3 of 3
  1. #1
    kg1
    kg1 is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Question java.system.class.loader Not Working

    Alrightey, I needed a way to replace the bootstrap class loader (the main-est class loader) with my own for applets, and I found out that you can do this by adding the java.system.class.loader property to the Runtime Parameters text that is in the Java Control Panel. However, it doesn't seem to work and I'm kinda stumped as to why.



    I set the Runtime Parameters text to:
    Java Code:
    -cp "C:\Documents and Settings\Yo\Desktop" -Djava.system.class.loader=CL2000
    And I also tried: -cp="C:\Documents and Settings\Yo\Desktop" (equals sign), but it made no difference.

    Here is my own class loader:
    Java Code:
    public class CL2000 extends ClassLoader {
    
    	public CL2000() {
    		commandUser();
    	}
    
    	public CL2000(ClassLoader parent) {
    		super(parent);
    		commandUser();
    	}
    
    	private void commandUser() {
    		System.out.println("eat it");
    	}
    
    }
    If it was working, the Java Console would contain the command to the user, but it doesn't because something's not right.

    So what am I doing wrong?

  2. #2
    lovelesh is offline Senior Member
    Join Date
    Nov 2010
    Location
    Delhi
    Posts
    135
    Blog Entries
    1
    Rep Power
    0

    Post

    I doubt if you can write a bootstrap class loader, coz a bootstrap class loader is integral part of jvm. As bootstrap class loader is responsible for loading core java classes like java.lang.object, etc. You must provide the logic to load all these classes.
    Moreover, it has to be written in native code.

  3. #3
    kg1
    kg1 is offline Member
    Join Date
    Dec 2010
    Posts
    2
    Rep Power
    0

    Default

    Okay, it's probably not the bootstrap class loader but the one that loads the non-standard, user-created classes (i.e., not ones like Object, Point, Canvas, but the ones old man Jenkins wrote).

    If I invoke a class that has a main method via the java command, everything seems to work fine.


    Java Code:
    java -Djava.system.class.loader=CL2000 SomeClass
    So that yields this in the console:
    Java Code:
    eat it //my class loader's message
    SomeClass executed!

    I thought maybe changing the location of files might do the trick. So I set the Runtime Parameters text to (and of course moved CL2000):
    Java Code:
    -cp="C:/" -Djava.system.class.loader=CL2000

    I think it works because instead of an applet loading as usual and not having the class loader message in the Java Console, it just shows a black box for the applet... and no Java Console on top of that.
    Now why's this happening?
    Last edited by kg1; 12-06-2010 at 10:45 PM. Reason: clarify

Similar Threads

  1. Replies: 6
    Last Post: 09-20-2010, 08:46 AM
  2. class loader problems!
    By alacn in forum New To Java
    Replies: 6
    Last Post: 08-11-2010, 11:51 PM
  3. How Add new classess to the System Classs loader.
    By echarish in forum Advanced Java
    Replies: 0
    Last Post: 02-02-2010, 11:54 AM
  4. TCCL (Thread context class Loader) ???
    By OutOfMemory in forum Advanced Java
    Replies: 0
    Last Post: 01-07-2010, 01:38 PM
  5. Class loader
    By JavaJunkie in forum New To Java
    Replies: 1
    Last Post: 05-06-2009, 02:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •