rJava dependency causing errors during installation of internal package


Hi all,

I've got a function in an internal package where i use the @import command in the roxygen headers, to specify that I need to import the mailR package. After documenting and checking in the package, I tried to re-install it - and I'm faced with a strange error.

Error: package or namespace load failed for 'myInternalPackage':
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/lakshmank/Documents/R/win-library/3.5/rJava/libs/i386/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.

mailR requires rJava, and the funny thing is - I'm able to install mailR (and rJava) outside of the package development framework, and get all functions within mailR package to work just fine.

Details about my working environment - I'm running R 3.5.0 (64 bit) and I've installed java, and can confirm that the rJava.dll exists in both the i386 as well as x64 folders in the rJava installed library. I've also set my JAVA_HOME and path variable correctly to me java installation of C:\Program Files\Java\jdk1.8.0_181\jre

Can anyone please point me in the direction of why this might be occurring?

I'm currently working around it by removing the @import command and specifying mailR:: for all functions and telling anyone who installs the package to also install mailR which is a bit of a crap way of working. Appreciate that this is a hard problem to communicate and hopefully I've provided relevant details. Would really be grateful if I can get any help to figure out what's going on.

Thanks very much.