Self executing jar with Plain Java API
![]()
Hi,
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 when startBuild is my class and login is a login method copied from snippet1: public static ITeamRepository login() throws TeamRepositoryException { 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
![]()
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
![]()
Are you calling com.ibm.team.repository.client.TeamPlatform.startup?
If so, and it's still not working, see 76455: Error running standalone java app. |
![]()
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.
|
![]()
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 com.ibm.team.build.toolkit jar. |
![]()
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 "java -jar jarName".
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. |
![]()
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 "How can I run the build engine on a platform other than Windows or Linux?" at: https://jazz.net/wiki/bin/view/Main/BuildFAQ#OtherPlatforms |
![]()
It could be a good idea. I'll take a look to it and make some test.
Thank you for the suggestion. Best regards, Michele. |