CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    3

    classloader question - same classes in 2 different jar files

    Hi, i have a question about classloader:

    I have few classes, for some reason, I have to put these classes in 2 different jar files, and both jar file will be in my class path. Will this cause any classloader problem? or any other problems?

    e.g.:

    I have
    a.class, b.class, c.class.....z.class

    I have to put above to both 1.jar and 2.jar

    My class path is C:\lib\1.jar;c:\2.jar;c:\3.jar....

    Will this cause any problems?

    Thanks !!!

  2. #2
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    Is the package the same?

    If not than the only thing that you will have to do is, provide the fully qualified package name when declaring variables. ie
    Code:
    ResultSet myResultSet = myStatement.executeQuery("SELECT * FROM SomeTable");
    
    java.util.Date utilDate = new java.util.Date();
    
    java.sql.Date sqlDate = myResultSet.getDate(1);
    Notice that the package is specified (java.util and java.sql)

    If the packages are the same, than you will run into problems

  3. #3
    Join Date
    Nov 2003
    Posts
    3
    Yes, packages are the same.... what kind of problem I will run into?

    Thanks.

  4. #4
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    I don't think that you will actually get errors, but the VM (Virtual Machine) will pick up the class it finds in the classpath first.

    ie if your classpath is something like:

    Test1.jar;Test2.jar

    Where Test1.jar has the same classes and packages as Test2.jar, the VM will pick to the classes in Test1.jar and not Test2.jar.

    I could be rong, I never tried it.

  5. #5
    Join Date
    Nov 2003
    Posts
    3
    Yes, this is what I thought

  6. #6
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104
    i'd love to know why you need to put identical classes in 2 different jar files, and use both jars in your app. it sounds like your filesystem structuring could do with some re-thinking
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured