How do I get the JavaPlatform associated with a Java Project?

View: New views
2 Messages — Rating Filter:   Alert me  

How do I get the JavaPlatform associated with a Java Project?

by Thorsen Eric-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is there a generic way to get the JavaPlatform associated with a Java  
Project?

Thanks,
Eric

Re: How do I get the JavaPlatform associated with a Java Project?

by Jesse Glick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thorsen Eric wrote:
> Is there a generic way to get the JavaPlatform associated with a Java
> Project?

You can always look up ClassPath.BOOT using ClassPath.getClassPath on a source root. Use ProjectUtils.getSources and JavaProjectConstants.SOURCES_TYPE_JAVA to find source
roots. (Usually all Java source roots will use the same boot classpath, though this is not guaranteed. Always true for plain Java SE projects.)

If you actually need the JavaPlatform instance for some reason, you can use JavaPlatformManager.getInstalledPlatforms and compare the bootstrapLibraries to the BOOT
classpath you got. Note that it is possible for some project types (e.g. apisupport) to report a BOOT classpath which does not correspond to a registered JavaPlatform,
e.g. if the JDK file path is specified directly in the project configuration and the user has not configured that path as a registered platform yet.