Closed Tungurahua closed 9 years ago
At work on a windows machine the sdmxhelp()
tools starts without flaws. So this is probably related either to OSX in general or to my specific setup. Is sdmxhelp()
known to work under OSX?
This https://github.com/s-u/rJava/issues/26 issues seems to address the same problem. However, I do not know how to 'start Java first and run R on a separate thread'. It's probably a basic task, but I don't know how to approach it.
I know that someone uses RJSDMX in OSX, but I'm not sure about the helper.
The issue you found for rJava seems related actually. Anyway I did not understand the workaround that was proposed. I'm investigating...
Regarding your previous question, to start the helper directly from java try:
java -classpath SDMX.jar it.bancaditalia.oss.sdmx.helper.SDMXHelper
Starting the helper directly works fine. Since the tool does not interact with the R session this provides full functionality as yet available.
I just committed a tentative fix for this issue (9d7092fc489973df857ac112e698b4f07e21c5c6), spawning the gui on a separate java thread. I'm not sure this will work and I cannot test since I don't have a mac at hand.
Can you please check if you see any difference in your environment?
Thanks.
Will do so tonight and let you know how it works out.
However, I have another question regarding the helper: am I right that this is basically just a browser of all available dataflows without any functionality of actually "pasting together" a REST call?
The background is that I need to work with Eurostat data a lot and building the REST query is a substantially painful issue. While Eurostat has a REST query builder in principle, this service is available only for some example flows. I saw that other sites like bancadiitalia provide export of REST strings so I was wondering if such a functionality could be implemented from client side.
If you have any hints how to ease the process of assembling REST calls from within R I would be very grateful.
While grepping works in principle, I am looking for something like a tabbed menu with checkboxes. If you could suggest a path to get this working with medium programming knowledge in R I would be grateful as well.
You are lucky, I'm working on something like that right now. :-)
This is a preview:
Awesome indeed! I'll be happy to test.
The tentative fix (9d7092f) changes the picture but does not solve the problem. The error log from the R-session is below.
> sdmxHelp()
Exception in thread "Thread-3" java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.<init>(Window.java:432)
at java.awt.Frame.<init>(Frame.java:403)
at javax.swing.JFrame.<init>(JFrame.java:202)
at it.bancaditalia.oss.sdmx.helper.SDMXHelper.<init>(Unknown Source)
at it.bancaditalia.oss.sdmx.helper.SDMXHelper$2.run(Unknown Source)
Setting of a system command from R works though
> system("java -classpath /Library/Frameworks/R.framework/Versions/3.0/Resources/library/RJSDMX/java/SDMX.jar it.bancaditalia.oss.sdmx.helper.SDMXHelper", wait=FALSE)
Mar 11, 2015 4:39:25 PM it.bancaditalia.oss.sdmx.util.Configuration init
INFO: Using global configuration.
I also found this snippet on SO, however I couldn't get it to work as I don't know what constructor
and method
are for the given case.
library(rJava)
.jinit(PATH_TO_YOUR_JAR) # this starts the JVM
jobject <- .jnew("yourJavaClass") ## call the constructor
.jcall(jobject ,"I",method="YOUR_METHOD") ## call a method
Hi, try this in a fresh session:
library(rJava);
.jinit(parameters=c("-Djava.awt.headless=false", "-Xmx2g", "-XstartOnFirstThread") );
library(RJSDMX)
Again a different picture, but still not starting the jar.
> library(rJava);
> .jinit(parameters=c("-Djava.awt.headless=false", "-Xmx2g", "-XstartOnFirstThread") );
> library(RJSDMX)
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
> sdmxHelp()
2015-03-12 19:44:01.896 rsession[11132:507] Apple AWT Java VM was loaded on first thread -- can't start AWT.
Error in .jfindClass(as.character(class)) : class not found
Ok, I think we tried what we could. I'll focus on this later, as soon as I have an OsX box for testing. In the meantime I changed the way the helper is started in R (9fcc2a895961c9b3aaa27807bd444ea855e0158f) and this should solve the problem. Please let me know if that's true in your environment.
Anyway I don't like this solution because
1 - it spawns a separate JVM 2 - it makes it impossible to return stuff in R. Today this is not necessary, but it could be useful for future enhancements.
For this reason I opened a new tracking issue (#42) for enhancing this behaviour.
Best, Attilio
That starts the helper from OsX. Although I agree that this will not suffice once the helper returns e.g. a REST-id, it has nevertheless helpful by enlightening me about file.path(find.package()
:-).
Best, Albrecht
Yes I discovered it recently and it was love at first sight :-)
Hi @Tungurahua, I just uploaded an early prototype of the new sdmx helper: a68f3da285977bb7f71546409b9086e70a1003b6
It is still very raw, not multi-threaded and probably with some bugs, but maybe you can find it useful for building your queries.
You can call it simply typing:
java -classpath SDMX.jar it.bancaditalia.oss.sdmx.helper.SDMXHelper2
or, from R:
system(paste0('java -classpath ', file.path(find.package('RJSDMX'), 'java', 'SDMX.jar'), ' it.bancaditalia.oss.sdmx.helper.SDMXHelper2'), wait=F)
I'll appreciate your feedback.
Best.
This is a great tool. Do you prefer to collect all comments in this thread or should I post them as seperate issues?
Thanks.
I think it's better to close this one and open separate new issues.
Cheers.
Closing as main problem solved. Issue #42 tracks enhancement request...
sdmxhelp()
does not work under OsX. When I run the command I get the following error message:If I understand it correctly R tries to run
RJSDMX/java/SDMX.jar. I found the
.jar` but couldn't run it from the terminal:I am stabbing in the dark here so it is quite possible that I am completely on the wrong path. Can you provide any hints how to get
sdmxhelp()
to work?With best regards Albrecht