Tag Archives: loadnamespace() error

Error. Onload failed when ‘rjava’ was calculated in loadnamespace()

64-bit Windows in installing rJava and Rwordseg times errors as well as solutions, the detailed procedure is as follows.

> install.packages('rJava')
--- Use the CRAN mirror for this connection phase ---.
试开URL’http://mirrors.xmu.edu.cn/CRAN/bin/windows/contrib/3.1/rJava_0.9-7.zip'
Content type 'application/zip' length 761221 bytes (743 KB)
The URL is open.
downloaded 743 KB

Package 'rJava' opened successfully, MD5 and check also passed.

The downloaded binary package is available in the
        C:\Users\asus\AppData\Local\Temp\RtmpUT48J3\downloaded_packages

There is no problem installing rJava through install.packages(‘ rJava ‘).

> library(rJava)
Error : loadNamespace().onLoad failed when calculating 'rJava', details.
  Call: inDL(x, as.logical(local), as.logical(now), ...)
  Error: Unable to load shared target 'C:/Program Files/R/R-3.1.3/library/rJava/libs/i386/rJava.dll'::
  LoadLibrary failure: %1 Not a valid Win32 application.

Error: 'rJava' programming package or namespace failed to load.

RJava loading error: The R client USES Windows 32bit, the operating system version is 64bit, and the system installed Java is 64bit, which is not compatible with rJava.

C:\Users\asus>java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) **64-Bit** Server VM (build 25.45-b02, mixed mode)

The solution, using a 32-bit JRE, is to reset the environment variable.

> Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre6')
> library('rJava')

Resetting the environment variables before loading rJava, OK

> install.packages("Rwordseg", repos = "http://R-Forge.R-project.org", type = "source")
试开URL’http://R-Forge.R-project.org/src/contrib/Rwordseg_0.2-1.tar.gz'
Content type 'application/x-gzip' length 5445754 bytes (5.2 MB)
打开了URL
downloaded 5.2 MB

* installing *source* package 'Rwordseg' ...
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
2015-8-31 11:34:07 org.ansj.util.MyStaticValue <clinit>
Warning: not find library.properties in classpath use it by default !
2015-8-31 11:34:08 org.ansj.library.UserDefineLibrary loadLibrary
Warning: init userLibrary  waring :library/default.dic because : not find that file or can not to read !
2015-8-31 11:34:08 org.ansj.library.UserDefineLibrary initAmbiguityLibrary
Warning: init ambiguity  waring :library/ambiguity.dic because : not find that file or can not to read !
2015-8-31 11:34:08 org.ansj.library.UserDefineLibrary loadFile
Message: init user userLibrary ok path is : C:\Program Files\R\R-3.1.3\library\Rwordseg\config\userdic
2015-8-31 11:34:09 org.ansj.library.InitDictionary init
Message: init core library ok use time :1570
2015-8-31 11:34:11 org.ansj.library.NgramLibrary <clinit>
Message: init ngram ok use time :1492
*** arch - x64
Agu 31, 2015 11:34:14 上午 org.ansj.util.MyStaticValue <clinit>
Warning: not find library.properties in classpath use it by default !
Agu 31, 2015 11:34:14 上午 org.ansj.library.UserDefineLibrary loadLibrary
Warning: init userLibrary  waring :library/default.dic because : not find that file or can not to read !
Agu 31, 2015 11:34:14 上午 org.ansj.library.UserDefineLibrary initAmbiguityLibrary
Warning: init ambiguity  waring :library/ambiguity.dic because : not find that file or can not to read !
Agu 31, 2015 11:34:14 上午 org.ansj.library.UserDefineLibrary loadFile
Message: init user userLibrary ok path is : C:\Program Files\R\R-3.1.3\library\Rwordseg\config\userdic
Agu 31, 2015 11:34:15 上午 org.ansj.library.InitDictionary init
Message: init core library ok use time :1107
Agu 31, 2015 11:34:16 上午 org.ansj.library.NgramLibrary <clinit>
Message: init ngram ok use time :675
* DONE (Rwordseg)

The downloaded package is available in the
        ‘C:\Users\asus\AppData\Local\Temp\RtmpUT48J3\downloaded_packages’
> library(Rwordseg)
# Version: 0.2-1       

Installation of Rwordseg is complete.
One thing to note here is the version of the JRE. Make sure it’s 32-bit.