I want to use JPL to create a graphic interface to my project, so I went and searched a code example to start working with, I downloaded the code but when I run it, it shows the following message:
ERROR: c:/program files/swipl/library/jpl.pl:4243:
'$open_shared_object'/3: Não foi possível encontrar o módulo especificado (this stands for "it wasn't possible to find the especified module)".
ERROR: c:/program files/swipl/library/jpl.pl:4243:
c:/program files/swipl/library/jpl.pl:4243: Initialization goal raised exception:
library `java' does not exist (Please add directory holding java.dll to %PATH%)
ERROR: c:/users/User/desktop/system/medical expert system.pl:4:
Exported procedure jpl:jpl_c_lib_version/1 is not defined
And when I try to use one function of the code it shows:
ERROR: Undefined procedure: jpl:jni_func/3
ERROR: In:
ERROR: [14] jpl:jni_func(6,'javax/swing/JFrame',_10490)
ERROR: [13] jpl:jFindClass('javax/swing/JFrame',_10522) at c:/program files/swipl/library/jpl.pl:1631
ERROR: [12] jpl:jpl_type_to_class(class([javax|...],['JFrame']),_10554) at c:/program files/swipl/library/jpl.pl:3049
ERROR: [11] jpl:jpl_new_1(class([javax|...],['JFrame']),['Expert System'],_10606) at c:/program files/swipl/library/jpl.pl:169
ERROR: [10] jpl:jpl_new('javax.swing.JFrame',['Expert System'],_10664) at c:/program files/swipl/library/jpl.pl:138
ERROR: [9] interface2 at c:/users/User/desktop/system/medical expert system.pl:180
ERROR: [7] <user>
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
I kinda tried to put the folder containing java.dll to the PATH in System Variables but it keeps showing the same message
My SWI-Prolog is version 7.6.4 64 bits, I don't think there's nothing wrong with the code itself because there's no one complaining about it in the video I downloaded it from.
Edit: the message saying that java.dll is now gone and now there's only the 2 other messages remaining, and I've already included everything I thought it was relevant in the Path under System Variables.
Make sure that the CLASSPATH variable in System Variables includes the path to the jpl.jar file that is bundled with SWI-Prolog. As in example, in my Windows 7 VM, I get from within SWI-Prolog:
?- getenv('CLASSPATH', P).
P = 'c:/program files/swipl/lib/jpl.jar'.
All of my code that uses JPL runs fine in this variable definition. In addition, loading the JPL library should print something like (assuming a recent SWI-Prolog version):
?- use_module(library(jpl)).
% Extended DLL search path with
% 'c:/Program Files/Java/jre1.8.0_201/bin/server'
% 'c:/Program Files/Java/jre1.8.0_201/bin'
Update
Experiment with also defining the JAVA_HOME variable in System Variables. I'm on macOS where I use:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
The path would differ on Windows and depending on the Java version you have installed but should end with HOME.
Related
I am working with R 4.2.1, 64bit, Windows 10.
while calling library rsubgroup, I get an error:
library(rsubgroup)
Loading required package: foreign
Error: package or namespace load failed for ‘rsubgroup’:
.onLoad failed in loadNamespace() for 'rsubgroup', details:
call: .jinit(parameters = parameters)
error: Unable to create a Java class loader.
rJava loads without problems.
I have installed Java 1.8.0_341 and JDK jdk-18.0.2
I have set-up manually JAVA_HOME and PATH variables.
Any hints what can go wrong with .jinit?
many thanks!
Solved, caused by my comp installation: R is installed in C:.../ProgramFiles that is write-protected (accessible only by "admin"); rJava and rsubgroup installed in the ...Users personal library. While moving all installation (core R, libraries) to writable disk, all starts to work. Apologies for this dumb question but I leave it here - perhaps could help somebody in future...
I try to install the RDRPOSTagger package through devtools.
devtools::install_github("bnosac/RDRPOSTagger", build_vignettes = TRUE)
Downloading GitHub repo bnosac/RDRPOSTagger#master
WARNING: Rtools is required to build R packages, but is not currently installed.
Please download and install Rtools 3.5 from http://cran.r-project.org/bin/windows/Rtools/.
√ checking for file 'C:\Users\X1\AppData\Local\Temp\RtmpUD2iwv\remotes70c59a944c1\bnosac-RDRPOSTagger-af51e38/DESCRIPTION' ...
- preparing 'RDRPOSTagger': (1.1s)
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'RDRPOSTagger_1.1.tar.gz'
Installing package into ‘C:/Users/X1/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'RDRPOSTagger' ...
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'RDRPOSTagger'
finding HTML links ... done
rdr_add_space_around_punctuations html
rdr_available_models html
rdr_model html
rdr_pos html
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'rJava':
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error : package 'rJava' could not be loaded
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/X1/Documents/R/win-library/3.5/RDRPOSTagger'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/X1/AppData/Local/Temp/RtmpUD2iwv/file70c8917649/RDRPOSTagger_1.1.tar.gz’ had non-zero exit status
Session Info:
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Java version on my CPU: java 10.0.2 64 bit
I try to use the qdap package which also needs rJava and this works just fine.
Error : package 'rJava' could not be loaded
This package is not loaded because JAVA_HOME is not set.
It can be done by first installing depending on your R (32 bit or 64 bit), Java 32 bit or 64 bit.
Download java from here: https://www.java.com/en/download/
Using this find JAVA_HOME address:
find.java <- function() {
for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment",
"Software\\JavaSoft\\Java Development Kit")) {
hive <- try(utils::readRegistry(key, root, 2),
silent = TRUE)
if (!inherits(hive, "try-error"))
return(hive)
}
hive
}
Load find.java and you will find the address for JAVA_HOME. Enter that address here:
Sys.setenv(JAVA_HOME='C:\\Your\\Java\\Directory')
library(rJava)
That should load the package rJava.
ERROR: loading failed for 'i386'
This error is maybe because you have downloaded both version of R (32 bit and 64 bit) and devtools tries to build for both of them.
You can use this:
devtools::install_github("mne-tools/mne-r", INSTALL_opts=c("--no-multiarch"))
I was also getting the similar type of error and after searching through I came across this solutions which worked for me.
I have been reading up on examples and cannot figure out the solution. I also had IT come by and they can't figure out why it isn't working also.
I am trying to use the 'rJava' package from R.
I uninstalled RStudio and R to get the latest versions.
Here is what I did:
install.packages('rJava')
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-9.zip'
Content type 'application/zip' length 720033 bytes (703 KB)
downloaded 703 KB
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Temp\RtmpSyCpeu\downloaded_packages
Then when I run below, this is what shows up:
library(rJava)
This same error message happens after I uninstalled RStudio and R.
When I click ok, below is the error that comes up.
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/nicknaue/Documents/R/R-
3.4.3/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
To try and solve for this, we downloaded the latest Java and also got a file from another program with the same name: jvm.dll and put it in the same file path. No luck also.
Has anyone come across this issue before?
Also, something weird, I have another computer where I tried this on and no errors came up.
I know there have been posts on this but I feel like I have tried everything at this point.
Figured out the answer from this link: Unable to load rJava on R
The issue was that I had 64-bit R and 32 bit Java. The two were not compatible before. You need 64 bit Java in order to run rJava if you have 64 bit R.
I am trying to call a Java class from an objective C, iPhone 5 application. I am using Xcode 4.5.1. At this stage, I can't even load the Virtual Machine without the following error:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_NSJavaVirtualMachine", referenced from:
objc-class-ref in main.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
These are the steps I have followed,
1) In main.m:
#autoreleasepool {
[NSJavaVirtualMachine defaultVirtualMachine]; //Added this line to load the Java VM.
id vector=[[NSClassFromString(#"java.util.Vector") alloc] init];
[vector add:#"one item!"];
NSLog(#"item 1=%#",[vector get:0]);
return 0;
}
2) I added the JavaVM.Framework by:
(right click on) frameworks -> "add files to project" -> JavaVM.Framework -> (Copy Items into destination group's folder and Create Folder References... -> Click Add
(It also shows up at Build Phases -> Link Binary with Libraries)
3) In info.plist, the following properties were added:
Cocoa Java Application = Yes
Java Class Path and Java Root Directory
Both were set to the global directory where I'm storing my Java files.
I'm trying to call the add and get functions of the Java class Vector. But I can't seem to load the VM into Xcode at all!
Please help.
You can't NSJavaVirtualMachine on iOS. The Cocoa/Java bindings are only available OS X and even there they are deprecated.
I’m really having trouble installing Pl/Java on Mac, any help would be appreciated.
I’ll describe the exact steps I’ve done in accordance with the README here, but I still get some errors that I cannot resolve.
(1) I’ve downloaded this version: pljava-i686-pc-linux-gnu-pg9.0-1.4.2
(2) I’ve located three files in the directory: pljava.jar, deploy.jar, pljava.so
(3) I’ve put the two .jars inside: /Library/PostgreSQL/9.0/lib
(4) I’ve put the .so inside: /Library/PostgreSQL/9.0/data
(5) I’ve modified the postgresql.conf as follows:
dynamic_library_path = '$libdir'
custom_variable_classes = 'pljava'
pljava.classpath = '/Library/PostgreSQL/9.0/lib/pljava.jar’
(6) I’ve also tried:
dynamic_library_path = '$libdir:/Library/PostgreSQL/9.0/lib/' (as well as...)
dynamic_library_path = '$libdir:/Library/PostgreSQL/9.0/data/'
(7) I then try to run:
Select sqlj.install_jar('/Software/Libraries/test_trigger.jar', 'samples', false);
Select sqlj.set_classpath(‘public’, ‘samples’);
Although, I keep getting this error:
WARNING: java.lang.NoSuchMethodError: Method org.postgresql.pljava.internal.Portal._fetch(JZI)I not found
ERROR: Unable to register native methods
********** Error **********
ERROR: Unable to register native methods
SQL state: XX000
This sounds like an issue is in not loading the right .jar. You mentioned in your comments that you were also having a problem with appropriate environment variables specifying where to load modules. This may in fact be your main issue. It looks like the equivalent environment variable is DYLD_LIBRARY_PATH though you can get more options by looking at man dyld and obviously if you are loading the wrong .so or .jar you will get errors like this.