{"id":901,"date":"2016-02-01T04:10:45","date_gmt":"2016-02-01T11:10:45","guid":{"rendered":"http:\/\/homepages.uc.edu\/~yaozo\/wordpress\/?p=901"},"modified":"2022-11-22T05:14:25","modified_gmt":"2022-11-22T05:14:25","slug":"rjava-in-rstudio-windows-and-library-xlsx","status":"publish","type":"post","link":"https:\/\/zhuoyao.net\/index.php\/2016\/02\/01\/rjava-in-rstudio-windows-and-library-xlsx\/","title":{"rendered":"rJava in RStudio, Windows, and library xlsx"},"content":{"rendered":"<div class=\"entry-body\">\n<div class=\"entry-content\">\n<p>This post is intended for users attempting to use the XLSX package in the Windows version of RStudio. I am using RStudio 0.98, R 3.1.2, Java 1.8.31 (all 64-bit).<\/p>\n<p>I&#8217;m assuming you have R and RStudio installed, and have attempted to use the xlsx package in order to import data from the Microsoft Excel format. When I attempted to load this package, I get an error like this:<\/p>\n<pre id=\"rstudio_console_output\" class=\"GEWYW5YBFEB\" tabindex=\"0\">&gt; library(\"xlsx\", lib.loc=\"~\/R\/win-library\/3.1\")\nLoading required package: rJava\nError : .onLoad failed in loadNamespace() for 'rJava', details:\n  call: inDL(x, as.logical(local), as.logical(now), ...)\n  error: unable to load shared object 'C:\/Users\/Charles\/Documents\/R\/win-library\/3.1\/rJava\/libs\/x64\/rJava.dll':\n  LoadLibrary failure:  The specified module could not be found.\n\nError: package \u2018rJava\u2019 could not be loaded<\/pre>\n<p>First; make sure you have the 64-bit edition of Java installed. This solved the issue on my girlfriends computer, but not mine.<\/p>\n<p>This nearly useless error message is due to the fact the system can&#8217;t locate jvm.dll. My solution was to append &#8220;;C:\\Program Files\\Java\\jre1.8.0_31\\bin;C:\\Program Files\\Java\\jre1.8.0_31\\bin\\server&#8221; to my path variable. You *may* need to adjust that path if you&#8217;re using a different version of Java, but I&#8217;ll leave finding that to you (and if you don&#8217;t have Java installed, try that first).<\/p>\n<h3>\nTHESE INSTRUCTIONS ARE FOR 64-BIT VERSION OF ALL SOFTWARE<\/h3>\n<h2>Adding to the PATH variable<\/h2>\n<p>Open the &#8220;System&#8221; panel by hitting the windows key and pause|break at the same time (or right clicking on my computer-&gt;properties in Windows 7, or right clicking on the windows icon at the bottom left-&gt;system in Windows 8), then open &#8220;Advanced System Settings&#8221;<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/logrit.com\/media\/filer_public\/0b\/52\/0b5294fa-f99e-4081-9695-92b07ad5c728\/system.png\" alt=\"System Settings\"><\/p>\n<p>In the System Properties window, go to the Advanced Tab, then click the &#8220;Environment Variables&#8221; button<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/logrit.com\/media\/filer_public\/e2\/10\/e2107d10-7efe-44ec-b15d-4710b248ceb0\/advanced.png\" alt=\"Advanced System Settings\"><\/p>\n<p>Search for the &#8220;Path&#8221; variable in the lower panel, the click edit<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/logrit.com\/media\/filer_public\/84\/ad\/84ade26d-8b01-432a-9dbf-acee0228d461\/path.png\" alt=\"Edit path\"><\/p>\n<p>And finally, append &#8220;;C:\\Program Files\\Java\\jre1.8.0_31\\bin;C:\\Program Files\\Java\\jre1.8.0_31\\bin\\server&#8221; to the path and click OK<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/logrit.com\/media\/filer_public\/f6\/9f\/f69fdee4-d489-4f5c-b9d5-7b703daf769b\/append.png\" alt=\"Append to path\"><\/p>\n<p>And finally, relaunch RStudio. You should now be able to load the packages!<\/p>\n<\/div>\n<\/div>\n<div class=\"entry-footer\">\n<p class=\"entry-tags\"><strong>Tags<\/strong> : <a title=\"Show all entries tagged by r\" href=\"http:\/\/logrit.com\/weblog\/tags\/r\/\" rel=\"tag\">r<\/a> <a title=\"Show all entries tagged by rstudio\" href=\"http:\/\/logrit.com\/weblog\/tags\/rstudio\/\" rel=\"tag\">rstudio<\/a> <a title=\"Show all entries tagged by windows\" href=\"http:\/\/logrit.com\/weblog\/tags\/windows\/\" rel=\"tag\">windows<\/a><\/p>\n<p class=\"entry-shorturl\"><strong>Short url<\/strong> : <a title=\"Short URL to RStudio, Windows, and library xlsx\" href=\"http:\/\/logrit.com\/weblog\/18\/\" rel=\"shortlink\">http:\/\/logrit.com\/weblog\/18\/<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This post is intended for users attempting to use the XLSX package in the Windows version of RStudio. I am using RStudio 0.98, R 3.1.2,&hellip; <\/p>\n","protected":false},"author":1,"featured_media":958,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-901","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-r"],"_links":{"self":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/comments?post=901"}],"version-history":[{"count":1,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/901\/revisions"}],"predecessor-version":[{"id":959,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/posts\/901\/revisions\/959"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media\/958"}],"wp:attachment":[{"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/media?parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/categories?post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhuoyao.net\/index.php\/wp-json\/wp\/v2\/tags?post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}