Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problem with ServiceLoader

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with ServiceLoader

    I have a service in form of interface and i want users to provide services ie give service providers by implementing my service
    Users provide services in from of jar files which also contains META-INF/Service/ package.Service file
    I am using follwing code in my main Class to load a service provider from jar but failed... i am using Eclipse ..

    URLClassLoader urlloader = new URLClassLoader(new URL[]{ new File("file:///c:/jars/Test.jar").toURI().toURL() });
    ServiceLoader<Foo> impl = ServiceLoader.load(Foo.class, urlloader);
    System.out.println("Using " + impl.getClass());

    Service provider is not loading by this code ...kindly help me!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Problem with ServiceLoader

    Please post your code correctly and post entire error messages and/or complete code that can be compiled and run to demonstrate the problem.

Similar Threads

  1. Catch block problem. Please fix my problem.
    By damnitsme in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 3rd, 2014, 01:49 AM
  2. Problem with Project Euler problem 18
    By sara_magdy in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 19th, 2013, 12:46 PM
  3. Replies: 3
    Last Post: January 5th, 2012, 01:44 AM
  4. [SOLVED] [Problem] imports javax.swing problem
    By Brollie in forum AWT / Java Swing
    Replies: 8
    Last Post: July 5th, 2009, 07:59 AM
  5. Java program for 2-D Array Maze
    By Peetah05 in forum Collections and Generics
    Replies: 11
    Last Post: May 8th, 2009, 04:30 AM

Tags for this Thread