0

For some reason this issue is to do with with gradle and yarn, no matter what I do to try and get the 'fabric-loom' plugin working, nothing works. It says i am using an outdated version of Java, that i'm on Java 11 (I'm not, I did 'java -version' in the bash terminal), I'm on Mac btw, and it said I'm on Java 16.0.2, which is the version it tells me to be on, I'll attach logs and some code I wrote. If someone could help me, that would be great, thanks in advance :)

Crash Log:

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip'. Build file '/Users/joeplemople/Desktop/joes blocks/build.gradle' line: 2 An exception occurred applying plugin request [id: 'fabric-loom', version: '0.9-SNAPSHOT'] Failed to apply plugin 'fabric-loom'. You are using an outdated version of Java (11). Java 16 or higher is required.

(This was outputted twice for some reason, idk why)

Terminal Code (Bash):

  • Displaying what versions of java I have installed JoepleMoples-MacBook-Pro:

joes blocks joeplemople$ /usr/libexec/java_home -V Matching Java Virtual Machines (2): 16.0.2, x86_64: "Java SE 16.0.2" /Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home 11.0.12, x86_64: "Java SE 11.0.12" /Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home

  • Me setting the default version of Java to Java (JDK) 16:

/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home JoepleMoples-MacBook-Pro:joes blocks joeplemople$ export JAVA_HOME=$(/usr/libexec/java_home -v 16.0.2) JoepleMoples-MacBook-Pro:joes blocks joeplemople$ java -version java version "16.0.2" 2021-07-20 Java(TM) SE Runtime Environment (build 16.0.2+7-67) Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

Thanks in advance :)

  • Maybe this helps? https://stackoverflow.com/a/56861298/7821823 If it doesn't, can you add the content of your build.gradle file to your question? – Mario Varchmin Aug 22 '21 at 08:11
  • when I try and do the command `$ /usr/libexec/java_home`, it doesnt show me a directory, it just says: "No such file or directory", does this mean that i don't have a jdk installed or does it mean i haven't got it set to "java_home" – JoepleMople Aug 22 '21 at 21:06

1 Answers1

0

Open Command Palette and choose Java: Configure Java Runtime, select jdk16 for both Project JDKs and Java Tooling Runtime.

Then reload window to make change effective and see if the error goes away.

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22
  • @JoepleMople. As the asker, you have the privilege that accept the answer if you think it's the best solution to your problem. Or vote up it that's helpful. See [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) – Molly Wang-MSFT Aug 23 '21 at 09:35
  • It still gives the same crash output, I managed to change the `Java Tooling Runtime`, but I couldn't and didn't change the `Project JDKs` because it says to change the JDK in use, you go in to the `build.gradle` and change the `sourceCompatability` and the `targetCompatability` to the JDK you want to use, (it also said change the `pom.xml` file, but i couldn't find it, because I'm not running a maven project) my sCom and tCom were both set to `JavaVersion.VERSION_16` and I still couldn't run it. – JoepleMople Aug 23 '21 at 18:50
  • ok so i've actually configured gradle correctly and set my java version to java 16, but now i'm getting an error when I try and run the Client environment that says `Exception has occurred: java.lang.ClassNotFoundException "java.lang.ClassNotFoundException: javax.servlet.Servlet"` It takes me to a file called `BuiltinClassLoader.class` to line 636, it says: `throw new ClassNotFoundException(cn); (cn = "javax.servlet.Servlet")` What do I do? – JoepleMople Aug 23 '21 at 22:05
  • @JoepleMople. Seems you didn't add the required dependencies [javax.servlet](https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api/4.0.1) to your project. Run the command **Java: Clean Java Language Server Workspace** from Command Palette, then add `compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'` to `build.gradle`. See if it helps. – Molly Wang-MSFT Aug 24 '21 at 02:55