I have next procedure to rename file on google drive, using REST with Google api. It's working with Delphi xe7.
Unfortunately with RAD 10 this procedure raise an exeption:
Java.net.ProtocolException unknown method 'Patch'... . I've read that it's because of java libraries. I changed paths
Tools-options-sdk manager - java to XE 7 java libraries, but it's useless.
Don't want to play Russian Roulette with random changing/updating setting, can someone tell me, what i should exactly update/change in RAD settings.
Thank you.
procedure ServerPatchDriveFile;
var
Folder : TJSONObject ;
FolderDest, itemmm : TJSONObject ;
parents: TJSONArray ;
begin
form2.RESTResponseDataSetAdapter1.AutoUpdate := false;
form2.RESTRequest1.Params.Clear;
form2.RESTRequest1.ClearBody;
form2.RESTClient1.AutoCreateParams:=false;
form2.RESTClient1.Accept:= '';
form2.RESTClient1.ContentType:= '';
form2.RESTRequest1.Method:= rmPATCH;
Form2.RESTClient1.BaseURL:='https://www.googleapis.com/drive/v2/files/{FileId}';
form2.RESTRequest1.Resource := '';
form2.RESTRequest1.Params.AddUrlSegment('fileId', UntitledId);
Parents:= TJSONArray.Create;
itemmm := TJSONObject.Create;
itemmm.AddPair(TJSONPair.Create('id', form2.EditIdFOlder.Text));
Parents.AddElement((itemmm));
Folder:= TJSONObject.create;
Folder.AddPair(TJSONPair.Create('title', 'Myfile'));
Folder.AddPair(TJSONPair.Create('parents', Parents));
form2.RESTRequest1.AddBody(Folder);
try
form2.RESTRequest1.Execute;
except
on e: Exception do
begin
ShowMessage(e.Message);//Show Exception
end;
end;
Folder.free;
Application.ProcessMessages;
end;
Related
I am running a Node application using GraalVM. My Node code contains both R and Java interop code.
I installed R using GraalVM Updater:
gu install r
Node program:
const express = require('express')
const app = express()
const BigInteger = Java.type('java.math.BigInteger')
app.get('/', function (req, res) {
var text = 'Hello World from Graal.js!<br> '
// Using Java standard library classes
text += BigInteger.valueOf(10).pow(100)
.add(BigInteger.valueOf(43)).toString() + '<br>'
// Using R methods to return arrays
text += Polyglot.eval('R',
'ifelse(1 > 2, "no", paste(1:42, c="|"))') + '<br>'
// Using R interoperability to create graphs
text += Polyglot.eval('R',
`svg();
require(lattice);
x <- 1:100
y <- sin(x/10)
z <- cos(x^1.3/(runif(1)*5+10))
print(cloud(x~y*z, main="cloud plot"))
grDevices:::svg.off()
`);
res.send(text)
})
app.listen(3000, function () {
console.log('Example app listening on port 3000!')
})
Console output:
Example app listening on port 3000!
FastR unexpected failure: error loading libR from: /.sdkman/candidates/java/20.1.0.r11-grl/languages/R/lib/libR.so.
Message: libgfortran.so.3: cannot open shared object file: No such file or directory
Troubleshooting:
* Please run /home/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/bin/configure_fastr. It will check that your system has the necessary dependencies and if not it will suggest how to install them.
* If this does not help, please open an issue on https://github.com/oracle/fastr/ or reach us on https://graalvm.slack.com.
/home/server.js:19
text += Polyglot.eval('R',
... other logs
I have also installed build-essential, gfortran, libxml2 and libc++-dev as suggested by GraalVm compiler.
Is it an issue with GraaLVM or Ubuntu FastR package installation does by GraalVM?
Please try again with the latest version of GraalVM. 20.1.0 is already several months old; if you try again with 20.3.0 you should get lots of bugfixed that where included in the newer version.
Also, note that the error message even tells you to run a specific command on your shell, /home/.sdkman/candidates/java/20.1.0.r11-grl/languages/R/bin/configure_fastr. Did you do that? Did that help? What was the output of that, was there an error?
Thanks,
Christian
When I start ensime in Emacs, it immediately crashes saying:
'"java"' is not recognized as an internal or external command,
operable program or batch file.
Process *inferior-ensime-server-documents* exited abnormally with code 1.
This is strange, because when I write java in cmd (in Windows 8), it runs. I added java both to Emacs's exec-path and the system's Path variables. Also I'm surprised it is in triple quotes, '"java"'. Do these quotes interfere? And what to do with them?
My .ensime file (created via sbt gen-ensime) looks like this:
(
:root-dir "C:\\Users\\leokr_000\\Documents\\skala"
:cache-dir "C:\\Users\\leokr_000\\Documents\\skala\\.ensime_cache"
:name "skala"
:java-home "C:\\Program Files\\Java\\jdk1.7.0_07\\bin"
:java-flags ("-Xmx512M" "-XX:MaxPermSize=256m" "-XX:ReservedCodeCacheSize=128m" "- Dsbt.log.format=true")
:reference-source-roots nil
:scala-version "2.10.4"
:compiler-args nil
:subprojects ((
:name "skala"
:module-name "skala"
:source-roots ("C:\\Users\\leokr_000\\Documents\\skala\\src\\main\\scala" "C:\\Users\\leokr_000\\Documents\\skala\\src\\main\\java" "C:\\Users\\leokr_000\\Documents\\skala\\src\\test\\scala" "C:\\Users\\leokr_000\\Documents\\skala\\src\\test\\java")
:target "C:\\Users\\leokr_000\\Documents\\skala\\target\\scala-2.10\\classes"
:test-target "C:\\Users\\leokr_000\\Documents\\skala\\target\\scala-2.10\\test-classes"
:depends-on-modules nil
:compile-deps ("C:\\Users\\leokr_000\\.sbt\\boot\\scala-2.10.4\\lib\\scala-library.jar")
:runtime-deps nil
:test-deps nil
:reference-source-roots ("C:\\Users\\leokr_000\\.ivy2\\cache\\org.scala-lang\\scala-library\\srcs\\scala-library-2.10.4-sources.jar")))
)
Your :java-home is wrong, I don't know how you can run anything in sbt with this setup. Remove the \\bin from this and investigate why it is being incorrectly generated.
I'm trying to install the most current platform (x64 or x86) appropriate Java Runtime Environment via Inno Setup (along with another application). I've found some script examples for how to detect the version and install if correct and adapted them to my needs but I keep running into this:
Unable to open file "path\to\JREInstall.exe":
CreateProcess failed: Code 5:
Access Is Denied
This is the code strictly responsible for installing the JRE:
[Setup]
AppName="JRE Setup"
AppVersion=0.1
DefaultDirName="JRE Setup"
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Files]
Source: "jre-8u11-windows-x64.exe"; DestDir: "{tmp}\JREInstall.exe"; \
Check: IsWin64 AND InstallJava();
Source: "jre-8u11-windows-i586.exe"; DestDir: "{tmp}\JREInstall.exe"; \
Check: (NOT IsWin64) AND InstallJava();
[Run]
Filename: "{tmp}\JREInstall.exe"; Parameters: "/s"; \
Flags: nowait postinstall runhidden runascurrentuser; Check: InstallJava()
[Code]
procedure DecodeVersion(verstr: String; var verint: array of Integer);
var
i,p: Integer; s: string;
begin
{ initialize array }
verint := [0,0,0,0];
i := 0;
while ((Length(verstr) > 0) and (i < 4)) do
begin
p := pos ('.', verstr);
if p > 0 then
begin
if p = 1 then s:= '0' else s:= Copy (verstr, 1, p - 1);
verint[i] := StrToInt(s);
i := i + 1;
verstr := Copy (verstr, p+1, Length(verstr));
end
else
begin
verint[i] := StrToInt (verstr);
verstr := '';
end;
end;
end;
function CompareVersion (ver1, ver2: String) : Integer;
var
verint1, verint2: array of Integer;
i: integer;
begin
SetArrayLength (verint1, 4);
DecodeVersion (ver1, verint1);
SetArrayLength (verint2, 4);
DecodeVersion (ver2, verint2);
Result := 0; i := 0;
while ((Result = 0) and ( i < 4 )) do
begin
if verint1[i] > verint2[i] then
Result := 1
else
if verint1[i] < verint2[i] then
Result := -1
else
Result := 0;
i := i + 1;
end;
end;
function InstallJava() : Boolean;
var
ErrCode: Integer;
JVer: String;
InstallJ: Boolean;
begin
RegQueryStringValue(
HKLM, 'SOFTWARE\JavaSoft\Java Runtime Environment', 'CurrentVersion', JVer);
InstallJ := true;
if Length( JVer ) > 0 then
begin
if CompareVersion(JVer, '1.8') >= 0 then
begin
InstallJ := false;
end;
end;
Result := InstallJ;
end;
In the full setup script the same message continues to come up.
How can I get the JRE Setup to run from this scripted setup file?
I was able to figure out the issue:
Evidently I was mistaken in my use of these lines:
Source: "jre-8u11-windows-x64.exe"; DestDir: "{tmp}\JREInstall.exe"; Check: IsWin64 AND InstallJava();
Source: "jre-8u11-windows-i586.exe"; DestDir: "{tmp}\JREInstall.exe"; Check: (NOT IsWin64) AND InstallJava();
and they should have been in place like so:
Source: "jre-8u11-windows-x64.exe"; DestDir: "{tmp}"; DestName: "JREInstall.exe"; Check: IsWin64 AND InstallJava();
Source: "jre-8u11-windows-i586.exe"; DestDir: "{tmp}"; DestName: "JREInstall.exe"; Check: (NOT IsWin64) AND InstallJava();
That seems to have solved the problem.
Also this line I was mistaken in:
Filename: "{tmp}\JREInstall.exe"; Parameters: "/s"; Flags: nowait postinstall runhidden runascurrentuser; Check: InstallJava()
It should have been:
Filename: "{tmp}\JREInstall.exe"; Parameters: "/s"; Flags: nowait runhidden runascurrentuser; Check: InstallJava()
This is the best solution my limited experience with this particular tool is able to come up with. I will look into the PrepareToInstall option when I have a chance but this works for now.
According to the initial question, "How do I install a JRE from an Inno script?", and taking as a starting solution the best proposed one, I propose a solution that I think works more coherently.
I understand that the user wants to install a JRE for their application if the target computer does not have installed a Java runtime environment or its version is lower than the required one. Ok, what I propose is to use the AfterInstall parameter and reorder a bit the distribution files in a different way.
We will first sort the files in the [Files] section in another way, putting first the redist install files.
Source: "redist\jre-8u121-windows-i586.exe"; DestDir: "{tmp}"; DestName: "JREInstaller.exe";\
Flags: deleteafterinstall; AfterInstall: RunJavaInstaller(); \
Check: (NOT IsWin64) AND InstallJava();
Source: "redist\jre-8u121-windows-x64.exe"; DestDir: "{tmp}"; DestName: "JREInstaller.exe"; \
Flags: deleteafterinstall; AfterInstall: RunJavaInstaller(); \
Check: IsWin64 AND InstallJava();
Source: "Myprog.exe"; DestDir: "{app}"; Flags: ignoreversion
The next step we must do is to modify the section [Run] as follows.
[Run]
Filename: "{app}\{#MyAppExeName}"; \
Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; \
Flags: nowait postinstall skipifsilent
And last but not least, we implemented in the [Code] section the RunJavaInstaller() procedure as follows:
[Code]
procedure RunJavaInstaller();
var
StatusText: string;
ResultCode: Integer;
Path, Parameters: string;
begin
Path := '{tmp}\JREInstaller.exe';
{ http://docs.oracle.com/javase/8/docs/technotes/guides/install/config.html#table_config_file_options }
Parameters := '/s INSTALL_SILENT=Enable REBOOT=Disable SPONSORS=Disable REMOVEOUTOFDATEJRES=1';
StatusText:= WizardForm.StatusLabel.Caption;
WizardForm.StatusLabel.Caption:='Installing the java runtime environment. Wait a moment ...';
WizardForm.ProgressGauge.Style := npbstMarquee;
try
if not Exec(ExpandConstant(Path), Parameters, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
{ we inform the user we couldn't install the JRE }
MsgBox('Java runtime environment install failed with error ' + IntToStr(ResultCode) +
'. Try installing it manually and try again to install MyProg.', mbError, MB_OK);
end;
finally
WizardForm.StatusLabel.Caption := StatusText;
WizardForm.ProgressGauge.Style := npbstNormal;
end;
end;
You may need to replace the Enabled value with 1 and the Disabled value with 0 if the Java runtime installer is not working properly. I have not experienced any problem doing it this way. Anyways, in the code you have a comment with the Oracle link if you want to take a look.
Finally, since unfortunately we can not receive the installation progress status of the JRE in any way, we show a message and a progress bar so that the user does not have the feeling that the installer has hung.
To do this, we save the state before, execute Exec with the flag ewWaitUntilTerminated, to wait for that installation to finish before continuing with ours, and we restore the previous state once the function execution has finished.
I'm trying to implement the Ruby Java Bridge (RJB) gem to talk to JVM so that I can run the Open-NLP gem. I have Java installed and running on Windows 8. All indications, at least those I know of, are that Java is installed and operational. But, attempts to use RJB fail with the message "can't create Java VM". (I do sometimes get "undefined method `dlopen' for Fiddle:Module" in other cases, which is also indecipherable.)
I initially just installed JDK per defaults. Due to my 64-bit system, this installed 64-bit Java. I wasn't sure whether or not Ruby and RJB would talk to this, so I installed the 32-bit JRE. However, the error is the same.
Is there any further test I can run to ensure that JVM is working outside of Ruby?
Can someone tell me what I might need to do to run Windows/Ruby/RJB/JVM?
Thanks...
I am running Windows 8 with BitNami Rubystack and Ruby 1.9.3p448.
Java seems to be available according to testjava.jsp:
This is the code, including the URL where I found it:
class FiddleTry
# http://devjete.wordpress.com/2011/01/31/installing-rjb-1-3-4-on-windows-7-32bit-wo-vc/
require 'rjb'
out = Rjb::import('java.lang.System').out <== Line 5 is here
out.print('Hello Rjb from ')
p out._classname
end
Here are the error messages:
C:/Users/Richard/RubymineProjects/Utilities/fiddle_try.rb:5:in `import': can't create Java VM (RuntimeError)
from C:/Users/Richard/RubymineProjects/Utilities/fiddle_try.rb:5:in `<class:FiddleTry>'
from C:/Users/Richard/RubymineProjects/Utilities/fiddle_try.rb:1:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
I cannot find any additional information as to why it "can't create Java VM". It would really help if additional information was available to me. I would appreciate either that information or a fix for this. Thanks...
EDIT TO ADD INFORMATION REGARDING OPEN-NLP REQUIREMENT FOR RJB...
This is the code I am trying to run, taken from Github/Open-nlp:
class OpenNlpSample
ENV['JAVA_HOME'] = "C:/Program Files/Java/jdk1.7.0_25" if ENV['JAVA_HOME'].nil?
ENV['LD_LIBRARY_PATH'] = "C:/Program Files/Java/jdk1.7.0_25/bin; C:/Program Files (x86)/Java/jre7" if ENV['LD_LIBRARY_PATH'].nil?
# Load the module
require 'open-nlp'
gem_bin = File.join(Gem.loaded_specs['open-nlp'].full_gem_path, 'bin/')
# Set an alternative path to look for the JAR files.
# Default is gem's bin folder.
# OpenNLP.jar_path = '/path_to_jars/'
# OpenNLP.jar_path = File.expand_path('../../ruby/lib/ruby/gems/1.9.1/gems/open-nlp-0.1.4/bin',__FILE__)
OpenNLP.jar_path = gem_bin
# Set an alternative path to look for the model files.
# Default is gem's bin folder.
# OpenNLP.model_path = '/path_to_models/'
OpenNLP.model_path = gem_bin
# Pass some alternative arguments to the Java VM.
# Default is ['-Xms512M', '-Xmx1024M'].
# OpenNLP.jvm_args = ['-option1', '-option2']
OpenNLP.jvm_args = ['-Xms512M', '-Xmx1024M']
# Redirect VM output to log.txt
OpenNLP.log_file = 'log.txt'
# Set default models for a language.
# OpenNLP.use :language
OpenNLP.use :english
=begin
Examples
Simple tokenizer
=end
OpenNLP.load
sent = "The death of the poet was kept from his poems."
tokenizer = OpenNLP::SimpleTokenizer.new
tokens = tokenizer.tokenize(sent).to_a
# => %w[The death of the poet was kept from his poems .]
#Maximum entropy tokenizer, chunker and POS tagger
OpenNLP.load
chunker = OpenNLP::ChunkerME.new
tokenizer = OpenNLP::TokenizerME.new
tagger = OpenNLP::POSTaggerME.new
sent = "The death of the poet was kept from his poems."
tokens = tokenizer.tokenize(sent).to_a
# => %w[The death of the poet was kept from his poems .]
tags = tagger.tag(tokens).to_a
# => %w[DT NN IN DT NN VBD VBN IN PRP$ NNS .]
chunks = chunker.chunk(tokens, tags).to_a
# => %w[B-NP I-NP B-PP B-NP I-NP B-VP I-VP B-PP B-NP I-NP O]
#Abstract Bottom-Up Parser
OpenNLP.load
sent = "The death of the poet was kept from his poems."
parser = OpenNLP::Parser.new
parse = parser.parse(sent)
parse.get_text.should eql sent
parse.get_span.get_start.should eql 0
parse.get_span.get_end.should eql 46
parse.get_child_count.should eql 1
child = parse.get_children[0]
child.text # => "The death of the poet was kept from his poems."
child.get_child_count # => 3
child.get_head_index #=> 5
child.get_type # => "S"
#Maximum Entropy Name Finder*
OpenNLP.load
text = File.read('./spec/sample.txt').gsub!("\n", "")
tokenizer = OpenNLP::TokenizerME.new
segmenter = OpenNLP::SentenceDetectorME.new
ner_models = ['person', 'time', 'money']
ner_finders = ner_models.map do |model|
OpenNLP::NameFinderME.new("en-ner-#{model}.bin")
end
sentences = segmenter.sent_detect(text)
named_entities = []
sentences.each do |sentence|
tokens = tokenizer.tokenize(sentence)
ner_models.each_with_index do |model,i|
finder = ner_finders[i]
name_spans = finder.find(tokens)
name_spans.each do |name_span|
start = name_span.get_start
stop = name_span.get_end-1
slice = tokens[start..stop].to_a
named_entities << [slice, model]
end
end
end
=begin
Loading specific models
Just pass the name of the model file to the constructor. The gem will search for the file in the OpenNLP.model_path folder.
=end
OpenNLP.load
tokenizer = OpenNLP::TokenizerME.new('en-token.bin')
tagger = OpenNLP::POSTaggerME.new('en-pos-perceptron.bin')
name_finder = OpenNLP::NameFinderME.new('en-ner-person.bin')
# etc.
#Loading specific classes
#You may want to load specific classes from the OpenNLP library that are not loaded by default. The gem provides an API to do this:
# Default base class is opennlp.tools.
OpenNLP.load_class('SomeClassName')
# => OpenNLP::SomeClassName
# Here, we specify another base class.
OpenNLP.load_class('SomeOtherClass', 'opennlp.tools.namefind')
# => OpenNLP::SomeOtherClass
end
At this point in the code:
=begin
Examples
Simple tokenizer
=end
OpenNLP.load
The call chain is to dl.rb, fiddle.rb and jar_loader.rb. jarloader.rb starting line 43:
# Load Rjb and create Java VM.
def self.init_rjb
::Rjb::load(nil, self.jvm_args)
set_java_logging if self.log_file
end
At this point, I get the same error creating JVM. So, I reverted to attempting to run RJB. The error chain is as follows:
Fast Debugger (ruby-debug-ide 0.4.17, ruby-debug-base19x 0.11.30.pre12) listens on 127.0.0.1:59488
Uncaught exception: can't create Java VM
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `load'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:45:in `init_rjb'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:38:in `load_jar_rjb'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/jar_loader.rb:27:in `load'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:63:in `load_jar'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:71:in `block in load_default_jars'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:68:in `each'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:68:in `load_default_jars'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/bind-it-0.2.7/lib/bind-it/binding.rb:55:in `bind'
D:/BitNami/rubystack-1.9.3-12/ruby/lib/ruby/gems/1.9.1/gems/open-nlp-0.1.4/lib/open-nlp.rb:14:in `load'
C:/Users/Richard/RubymineProjects/Utilities/open_nlp_sample.rb:32:in `<class:OpenNlpSample>'
C:/Users/Richard/RubymineProjects/Utilities/open_nlp_sample.rb:1:in `<top (required)>'
First, I needed to uninstall Java x64 and install JDK x586 for 32-bit support.
Then, set JAVA_HOME as follows:
JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_40
and add JAVA_HOME to my path:
%JAVA_HOME%\bin;C:\Program Files (x86)\Java\jre7\bin;
This resolved the "can't create Java VM' problem.
Setting $DEBUG=false, or commenting out the line, eliminated all other messages. $DEBUG mode displays error messages that may be caught and resolved so they can be ignored.
After the "can't create Java VM" problem was resolved, all other error messages were of this type and therefore were spurious.
JetBrains support for Rubymine solved this problem for me. They are very good, especially Serge, and I recommend their products because of their support.
My customer wants to be able to call a jar file from Oracle PL/SQL.
Java 1.6, Oracle 11g R2
How do I do this?
I did a bit of research into loadjava (the program that loads classes into Oracle).
Sounded like a pain in the butt.
So I opted to run my jar outside Oracle but called from Oracle DBMS_SCHEDULER by PL/SQL.
Here's how:
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'testjar',
program_type => 'EXECUTABLE',
program_action => 'C:\MYSTUFF\testjar.bat',
enabled => TRUE,
comments => 'test testjar'
);
END;
/
begin
dbms_scheduler.create_job
(job_name => 'testjar_job',
program_name=> 'testjar',
enabled=>true,
auto_drop=>false,
comments=>'Only run immediately by dbms_scheduler.run_job');
end;
/
begin
dbms_scheduler.run_job('testjar_job',TRUE);
end;
/
After playing around I found out that the schema JAR_NAME.jar///ClassName.methodName(.... works.
So for example:
Function do()
return String
AS
LANGUAGE java
NAME 'my_jar.jar///MyClass.myMethod() return oracle.sql.String';
Note that it seems like some jar name files does not work. For example I had problems with a "-" in jar.