0

I am working on my Minecraft mod, and I would like to use a switch statement with a string in it. However, Minecraft's Gradle setup is set to compile against Java 6, which does not support switch statements on strings. How do I change what Minecraft's Gradle is compiling against?

Thank you!

EDIT:

After looking at the "similar" question, I am still stuck. Because this is a Minecraft Forge Gradle project, this is a bit different. I do not have a gradle.properties file.

I also the other popular method of fixing this:

compileJava.options.fork = true compileJava.options.forkOptions.executable = /path_to_javac

However, Gradle refused my path due to the ':' character, and I cannot get specify a path without it to my knowledge. Are there any other options? Or am I going to have to live in Java 6?

Thank you!

SneakyTactician
  • 130
  • 1
  • 14
  • 1
    java 6, why in the world.. – Javant Jul 29 '16 at 20:16
  • I don't know why it is set to that by default, but it is. Could someone help me change it to Java 8? – SneakyTactician Jul 29 '16 at 20:19
  • 1
    Possible duplicate of [How do I tell Gradle to use specific JDK version?](http://stackoverflow.com/questions/18487406/how-do-i-tell-gradle-to-use-specific-jdk-version) – azurefrog Jul 29 '16 at 20:37
  • use an if statement instead – chiliNUT Jul 29 '16 at 21:24
  • 1
    You may create a gradle.properties file if one does not exist, in the same directory as your build.gradle. If you would add the contents of your build.gradle, it would help. As for rejecting the ':', try wrapping your path in doublequotes. – Jordan Grant Jul 29 '16 at 22:32

1 Answers1

2

Be aware that Minecraft Forge installation docs state that it officially supports Java 6 and 7, but it should be backwards compatible.

Install Java 8 Standard Edition SDK and set your JAVA_HOME environment variable to point to the path in which you installed it.

The build.gradle file may have a property sourceCompatibility. If it doesn't or is set incorrectly, set it like so:

sourceCompatibility=1.8

If you are using an IDE, you will need to make sure that it is also aware that it can expect java 1.8 source.

Jordan Grant
  • 860
  • 7
  • 12