Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java version error #57

Open
AdamWallach opened this issue Jul 23, 2024 · 4 comments
Open

Java version error #57

AdamWallach opened this issue Jul 23, 2024 · 4 comments

Comments

@AdamWallach
Copy link

Whenever I try to require(rjd3toolkit), I get this error: "Your java version is 1.8.0_402. N or higher."

I've tried it on the newest Java, on Java 1.7, and on Java 17, and I'm not sure what does it want me to do.

What is the correct Java setting for this toolkit?

@TanguyBarthelemy
Copy link
Contributor

Hi,

Java >= 17 is required for {rjd3toolkit}. R detects version 1.8.0_402 which is insufficient.
You need to configure manually your java path in an environment variable.
You can find information on configuration here: https://jdemetra-new-documentation.netlify.app/#Rconfig

To sum up, you just need to set up the JAVA_HOME variable on R with the following command, which points to the location of your java installation:

Sys.setenv("JAVA_HOME" = ".../your/java/installation/path")

@AQLT
Copy link
Contributor

AQLT commented Jul 23, 2024

However, the message is indeed unclear and should mentioned the required version. Something like "Your java version is 8. 17 or higher is required."

@AdamWallach
Copy link
Author

I have followed the instructions provided by the link, and it still won't work. No clue as to what the problem is.

@AQLT
Copy link
Contributor

AQLT commented Jul 24, 2024

We suppose that you are using Windows, otherwise give more details on your OS and R version.
If you still have an error then it means that your R session is still using the wrong Java version. To check which version is detected by R you can use the following code:

library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

In your case it will surely return 1.8.0_402 which means Java 8. When you have multiple version you have to specify which version to use with the JAVA_HOME environment variable. In R run:

Sys.getenv("JAVA_HOME")

You can run the following command to see which version is used by the system (which might be different from the one used by R) and where it is located

system("java --version")
system("which java")

In your case I suspect that it will return the path to the installation of JAVA 8 or an empty character. When you change this environment variable you have to restart R. So find the path to JAVA 17, restart R and run

Sys.setenv(JAVA_HOME='pathToJava') # replace with your path
# Now we can test the Java version detected
library(rJava)
.jinit()
.jcall("java/lang/System", "S", "getProperty", "java.runtime.version")

If you have an error loading rJava it means that you wrongly specified the path to Java. It the result is something like "17.x.x.x+x-x" then the correct path is specified and you will have to run the Sys.setenv() command each time you open R. For more permanent solution you can modify the .Renviron file (as mentioned in Tanguy's url) or the JAVA_HOME environment variable (Windows settings).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants