Reconfiguring Java for R

If anyone should attempt to create a connection to a database using the Java Database Connectivity (JDBC) package in R, that person might encounter something such as the following:

> library(RJDBC)
Loading required package: DBI
Loading required package: rJava
> drv <- JDBC("org.postgresql.Driver","/data/drivers/postgresql-9.4-1201.jdbc41.jar")
Error in .jinit(classpath): Unable to create a java class loader

The solution is to quit out and execute the following command from bash:

$ sudo R CMD javareconf

And the error will be resolved!  That command simply reconfigures R with the environment variables appropriate to the currently-installed Java packages.

Advertisements
This entry was posted in Information Technology and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s