2

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

Eric
  • 16,397
  • 8
  • 68
  • 76
  • It seems to be JME. Try to download and install the JME-SDK and use that as your "JDK". – Olivier Grégoire Aug 05 '16 at 19:58
  • A bit late... but I had a similar need and I managed to remove the JDK entry with a custom plugin: https://intellij-support.jetbrains.com/hc/en-us/community/posts/4412552552722-Remove-JRE-entry-from-External-Library-for-Android-Studio-project (it is for Android Studio but I guess it should work for IntelliJ IDEA as well). – Thomas Nov 18 '22 at 15:52

1 Answers1

-3

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

Antony Joslin
  • 309
  • 4
  • 17