As was some of you noted after yesterday's class, several the functions I demo'd required that you have the rJava package installed and properly configured. The rJava package requires that you have the Java Development Kit JDK installed. Note that while we all of Java installed on our machines, very few will have the JDK, unless you needed to have it for some other purpose.
If you ran some of the functions I showed in class and got an error related to rJava, you can follow the steps below to fix this and get everything working.
Step 1 - Install the JDK for your system
a. Go here and click on the .exe for your system
b. Follow the propmts to accept the defaults
Step 2 - Find the JDK on your system
a. On Windows the JDK should have installed in the Program Files/Java directory
b. In that directory there should be a folder with jdk in the name.
Step 3 - Store your JDK path as an environment variable
a. When you installed the R/RStudio toolchain at the start of the quarter you were introduced to the concept of environment variables
b. These are variable that describe & define your machine's computing environment (duh)
c. We need to tell other systems on your machine where to find the JDK
d. We do this by same the JDK address (path) as a new environment variable
e. You can see a list of your machine's current environment variables by running Sys.getenv() in the R console
f. To create a TEMPORARY environment variable you can use Sys.setenv('variable_name' = 'variable_value')
g. For the JDK we need to set an environment variable with a specific name, which is JAVA_HOME. The value assigned to this variable is the path to your installed JDK. On my machine that path is C:\Program Files\Java\jdk1.8.0_161
h. So, we can create this variable temporarily using Sys.setenv('JAVA_HOME' = 'C:\Program Files\Java\jdk1.8.0_161')
i. This is temporary because when you shut down R this variable is destroyed
j. To create a permanent environment variable, click start and search for 'environment'
k. Click on 'Edit Environment Variables for Your Account'
l. In the top window click 'New'
m. In the 'Variable name' field type JAVA_HOME - all caps
n. In the 'Variable Value' filed paste the path to your locally installed JDK
Step 4 - Restart R/Rstudio
a. Since we've changed your machines computing environment, we need to shut down RStudio and re-open it to pick up the changes.
b. In the R console window type library(rJava), this should now run without issue - no news is good news
c. If you still get an error post what you are seeing as comment to this issue
As was some of you noted after yesterday's class, several the functions I demo'd required that you have the
rJava
package installed and properly configured. TherJava
package requires that you have the Java Development Kit JDK installed. Note that while we all of Java installed on our machines, very few will have the JDK, unless you needed to have it for some other purpose.If you ran some of the functions I showed in class and got an error related to
rJava
, you can follow the steps below to fix this and get everything working.Step 1 - Install the JDK for your system
a. Go here and click on the .exe for your system b. Follow the propmts to accept the defaults
Step 2 - Find the JDK on your system
a. On Windows the JDK should have installed in the
Program Files/Java
directory b. In that directory there should be a folder withjdk
in the name.Step 3 - Store your JDK path as an environment variable
a. When you installed the R/RStudio toolchain at the start of the quarter you were introduced to the concept of environment variables b. These are variable that describe & define your machine's computing environment (duh) c. We need to tell other systems on your machine where to find the JDK d. We do this by same the JDK address (path) as a new environment variable e. You can see a list of your machine's current environment variables by running
Sys.getenv()
in the R console f. To create a TEMPORARY environment variable you can useSys.setenv('variable_name' = 'variable_value')
g. For the JDK we need to set an environment variable with a specific name, which isJAVA_HOME
. The value assigned to this variable is the path to your installed JDK. On my machine that path isC:\Program Files\Java\jdk1.8.0_161
h. So, we can create this variable temporarily usingSys.setenv('JAVA_HOME' = 'C:\Program Files\Java\jdk1.8.0_161')
i. This is temporary because when you shut down R this variable is destroyed j. To create a permanent environment variable, click start and search for 'environment' k. Click on 'Edit Environment Variables for Your Account' l. In the top window click 'New' m. In the 'Variable name' field typeJAVA_HOME
- all caps n. In the 'Variable Value' filed paste the path to your locally installed JDKStep 4 - Restart R/Rstudio
a. Since we've changed your machines computing environment, we need to shut down RStudio and re-open it to pick up the changes. b. In the R console window type
library(rJava)
, this should now run without issue - no news is good news c. If you still get an error post what you are seeing as comment to this issue