It's all about the answers!

Ask a question

Self executing jar with Plain Java API

Michele Pegoraro (1.8k14119103) | asked Sep 08 '09, 5:31 a.m.
I've developed a plain java class which launch a build definition, and it works fine using RTC eclipse run configuration. I've tried to export my class using built-in Executable jar export using the same run configuration.

But when I try to run my jar from command line I've got an exception:
Exception in thread "main" java.lang.ExceptionInInitializerError

at java.lang.J9VMInternals.initialize(
at it.nexen.test.plain.StartBuild.login(
at it.nexen.test.plain.StartBuild.main(

Caused by: java.lang.IllegalArgumentException: The type name Contributor and the namespace URI do not resolve to an IItemType.
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(
... 6 more

when startBuild is my class and login is a login method copied from snippet1:
public static ITeamRepository login() throws TeamRepositoryException {

ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(REPOSITORY_ADDRESS);
repository.registerLoginHandler(new ITeamRepository.ILoginHandler() {
public ILoginInfo challenge(ITeamRepository repository) {
return new ILoginInfo() {
public String getUserId() {
public String getPassword() {
return "password";
System.out.println("Contacting " + repository.getRepositoryURI() + "...");
return repository;

It seems that error is on TeamPlatform.getTeamRepositoryService().getTeamRepository(REPOSITORY_ADDRESS) line, but the things is that running on client it works perfectly.
Any idea?

Accepted answer

permanent link
Thomman TJ (9521111) | answered May 13 '15, 4:50 p.m.
I too faced same issue,  resolved by changing the way jar file got generated from eclipse client. Followed the steps mentioned below
Step 1: Right on Project , select export

Step 2 : In export wizard, page 1, select the option
                Java > Runnable Jar file

Step 3 :  In export wizard, page 2, 
                         a) Launch configuration : select the Main Class
                         b) Specify Export Destination e.g C:\Temp
                         c) Library handling 
                                    use the option : Copy required libraries into a sub-folder next to the generated JAR

Now to verify the jar, Go to export destination e.g. C:\Temp
  use the command 
                  # java -jar <jarfilename.jar>



Michele Pegoraro selected this answer as the correct answer

6 other answers

permanent link
Nick Edgar (6.5k711) | answered Sep 09 '09, 3:35 p.m.
Are you calling

If so, and it's still not working, see 76455: Error running standalone java app.

permanent link
Michele Pegoraro (1.8k14119103) | answered Sep 10 '09, 5:39 a.m.
Currently I think to have found the problem. I've to add the classpath to API passing -Djava.ext.dirs=pathToAPI . I was hoping that classes would be in the jar (as the compiled executable jar is something like 23Mb) but if I have to pass classpath I would call the .class intead of the jar.

permanent link
Nick Edgar (6.5k711) | answered Sep 10 '09, 9:40 a.m.
Your jar and the 'API' jars (I assume you mean the plug-in jars from Jazz/RTC) all need to be on your classpath, but you shouldn't need to use -Djava.ext.dirs, or have .class files outside of a jar.

I'm not sure what you mean by 'as the compiled executable jar is something like 23Mb'. Are you adding the Jazz/RTC jars to an enclosing jar? Normally they're all at the same level.

For an example of the kind of organization you can have for a standalone Java client to RTC, see the buildengine/buildtoolkit directory in the Build System Toolkit. All the jars here are added to the classpath via Ant's -lib argument. The entry-point is typically one of the Ant tasks in the jar.

permanent link
Michele Pegoraro (1.8k14119103) | answered Sep 11 '09, 5:49 a.m.
I'm not very used with executables jar and probably I'm doing something conceptually wrong. But what I'd like to have is a jar which I can execute directly using &quot;java -jar jarName&quot;.

In jar I've created in my test I can't do this because I've always error on finding class related to plug-in jars of PlainAPI and I resolve this only using -Djava.ext.dirs option (only setting the CLASSPATH env variable doesn't run).

I've tried to put all these java into my jar (and so I have the large amount of Mb), using Class-Path reference on Manifest and I've also tried to use build-in Eclipse wizard to create executable jar and it takes all api jar and put their classes into my jar (as I've develped them).
In both cases I've always the same missing class error.
I agree that this is not the correct way, because I've to rebuild my jar every time API jars will change, but I would like to have this kind of option.

permanent link
Nick Edgar (6.5k711) | answered Sep 11 '09, 10:26 a.m.
Have you considered running it as an Eclipse/OSGi application instead of standalone Java? For example, the build engine process, jbe, runs this way.
It can then be invoked with a simple command (jbe, which is simply eclipsec.exe renamed). Or you can use: java -jar plugins/{equinox launcher jar}
For more details, see &quot;How can I run the build engine on a platform other than Windows or Linux?&quot; at:

permanent link
Michele Pegoraro (1.8k14119103) | answered Sep 11 '09, 10:51 a.m.
It could be a good idea. I'll take a look to it and make some test.
Thank you for the suggestion.

Best regards,

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.