Results 1 to 5 of 5

Thread: [java] ClassLoader

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default [java] ClassLoader

    Hello,

    I need to use ClassLoader;
    For instance, I've got this problem:
    Qt Code:
    1. Class t = Class.forName("java.lang.Thread");
    2. Class c = Class.forName("myclass.class") ;
    To copy to clipboard, switch view to plain text mode 
    The first works fine; the second launch an exception (it says file not found); the file is in the directory of project; I tried to move it to \bin dir, but the same
    Besides, could anyone suggest me any fine link? (java api doens't like to me)....

    Thanks to all
    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [java] ClassLoader

    The parameter to Class.forName is not the compiled class file, but the class name, where you need to prefix the package name.

    Just use google for in-depth explanations.

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: [java] ClassLoader

    I've just see it....but "MyClass" (the name only I know) isn't in any package; this class isn't part a my project; it's a class that I created my own from an editor....
    Regards

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [java] ClassLoader

    Then you can add this class to the class path... either by using a meta info file or just by packaging it to a jar and adding it to the global CLASSPATH env var.

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: [java] ClassLoader

    hello,
    yes that the problem; but how solve from program?
    See at this similar problem:
    Qt Code:
    1. class myClass {
    2. URL D = this.getSystemResource(className);
    3. }
    To copy to clipboard, switch view to plain text mode 
    className is "name.class" and it's in the directory of "eclipse project file"; D is always "null"; I just see around web and it seems a popular problem but i don't still find the solution....

    could you help me, please?

    thanks,
    Regards

Similar Threads

  1. [java] write a simple server
    By mickey in forum General Programming
    Replies: 0
    Last Post: 22nd July 2008, 00:59
  2. [java] manipulate a string
    By mickey in forum General Programming
    Replies: 5
    Last Post: 10th July 2008, 20:22
  3. [Java] read and write a file
    By mickey in forum General Programming
    Replies: 3
    Last Post: 22nd June 2008, 10:43
  4. [java] access to member in composition
    By mickey in forum General Programming
    Replies: 2
    Last Post: 21st June 2008, 22:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.