Skip to content

How to add JDK ≥ 9 modules as dependencies #1371

@ayanamists

Description

@ayanamists

It's not a bug.

I'm using JDT as a library instead of run a eclipse container, so I can't make use of apis like IJavaProject. Currently, I could set my jar dependencies by ASTParser::setEnvironment function. For example:

parser.setEnvironment(cp, null, null, false);

By including all JARs (especially, rt.jar) in cp, JDT can correctly parse/resolve my java source file. However, since Java 9, the JDK uses modules to distribute the JRE, and there are no longer such JARs as rt.jar.

I found two workarounds:

  1. Packing all JRE modules into a jar file.
  2. Setting the includeRunningVMBootclasspath flag of setEnvironment to true, so that JDT will use the current JVM's JRE.

However, I want to know if there's way to add a JRE module as a dependency of ASTParser? Just like include rt.jar in the classpath (cp).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions