Making barebones ServiceLoader run

Hi there,

I tried to make a little source code example employing the ServiceLoader-Class http://download.oracle.com/javase/6/docs/api/index.html?java/util/ServiceLoader.html included in JDK 1.6 (find sources attached) which uses the file /META-INF/sources/example.IHelloWorld runnable in IntelliJ".

Interestingly, compiling worked but the required file in /META-INF/services/example.IHelloWorld wasn't copied into the /out folder even though everything is located within in /src-folder.
After packaging it within a single jar-artifact and explicitly including the file mentioned above, the example worked, starting from the command line (outputting "hello world"). Sadly, I did not find a way to start the example using IntelliJ (I tried "Run/Application/".

Could you please answer whether:
1) it is necessary to use an artifact for that?
2) is it possible to start the compiled code right off the IDE?

Thanks in advance,
Romeo



Attachment(s):
src.zip
2 comments

Hi Romeo,

It looks like you have incorrect IJ setup. Can you provide complete project (with project files included).

Denis

0

Hello Denis,

thanks for your reply. Please find the request zip archive of the whole project attached.

Romeo



Attachment(s):
ServiceLoaderExample.zip
0

Please sign in to leave a comment.