How to remove the java standard library from a gradle project?

968 Views Asked by At

How can one make Gradle not include the Java standard library as a dependency to IntelliJ IDEA project?

I am using IntelliJ and every time I Refresh all Gradle projects:

enter image description here

IntelliJ adds the Java standard library back to the project as an external dependency:

enter image description here

So I have to manually remove it every single time:

enter image description here

Things I tried that didn't work out

  • fiddling with the sourceCompatibility and targetCompatability properties...

  • applying the idea plugin to Gradle and setting idea.project.jdkName to null.

Background

  • I'm writing a program for the Lego NXT Brick

  • I'm using Lejos so I can write the program in Java

  • Lejos' "standard library" for the Lego brick is only a fraction of the actual Java standard library....(because of memory constraints?)

  • Lejos provides a JAR file that contains all the classes of their standard library to assist in programming. I've added this JAR as a dependency of the project.

  • Gradle also (implicitly?) adds the actual java standard library as a dependency to the project, which obscures Lejos' standard library classes since they use the same names...

P.S. at least this is what I think is happening....please correct me if I'm wrong

1

There are 1 best solutions below

1
Antony Joslin On

You better create a user variable like %JAVAHOME% in enivronment variables and give it in path in the system variables. use 1.7 in javahome and 1.8 in javahomeb when you want 1.8 just rename the variable