new Rengine(...); fails without error - java

I'm trying to set up JRI with Eclipse on a Windows 7 x64 system. I tried it once on my Laptop and it worked. Now on my Desktop it fails although everything of the R, rJava and JRI installation is exactly the same.
I set the JRI and R Paths correctly to:
C:\Program Files\R\R-2.15.1\library\rJava\jri;C:\Program Files\R\R-2.15.1\bin\x64
Also I set R_DOC_DIR etc in Eclipse.
Every time I try to run new Rengine(...); it fails without any error or exception. Debugging revealed an: <terminated, exit value: 10>C:\Program Files\Java\jre6\bin\javaw.exe (01.10.2012 18:00:31)
Is there anything I can try? It really bothers me that it works an my Laptop but not on my Workstation despite the same settings everywhere.
Edit: The code that is used to get the Rengine object.
public static Rengine getRengine(){
if (re == null) createRengine();
return re;
}
public static void createRengine(){
if (re!=null) return;
try{
if (!Rengine.versionCheck()) {
System.err.println("** Version mismatch **");
System.exit(1);
}
String[] arguments = {"--save"};
re=new Rengine(arguments, false, null);
if (!re.waitForR()) {
System.out.println("Cannot load R");
return;
}
}
catch (Exception e){
e.printStackTrace();
}
}
Edit: The last time i tried it i got an errormessage (creating of the REngine worked, this happened never before), R was missing a registryentry. After installing R 2.15.1 again it suddenly worked. Now after a restart it's the same like before. The program crashes at the creation of the REngine.

I was having the exact same problem. It turns out I had unchecked the box that asks to make a registry entry with the R version number. Once I let the installer run with that box checked, it seemed to work.
I would make sure your regedit looks like this:
Next up: getting this working in a portable way...

I am using R 3.2.2 and eclipse Mars on Windows 10 x64.
I faced the described issue today and tried around a bit. Finally, I found the root cause in the build path. Please check whether the following conditions are fulfilled:
1.) The following Java libraries from the JIRI folder on your hard disk shall be included as (user) libraries:
JIRI.jar
REngine.jar
JRIEngine.jar
2.) The native library jiri.dll is located in the subfolder "i386" for x86, whereas for x64 it is available in the subfolder "x64". The relevant one shall be added as separate native library location to the Java Build Path of the eclipse project. Otherwise, the file may not be considered as it is not located in the main JIRI folder.
Best regards
Philipp

Related

NetBeans cannot connect to repository at (gitlab repository)

Yesterday I installed a new version of Netbeans (NetBeans IDE 8.2 (Build 201705191307)) and since then I can't connect to my gitlab repo (fails on trying to clone project). Credentials are fine, work on other computers and systems and I logged in over the browser(my first thought was that I tried a wrong password and banned my IP).
I use Windows 10, Java 1.8.0_31.
EDIT: Access to gitlab worked on an older version of NetBeans (not sure which one was it but above 8.0)
Updated JDK to 1.8.0_171 - still no success.
Also this was found in IDE log
INFO [org.netbeans.modules.git]: java.lang.InternalError: Should not get here
java.lang.InternalError: Should not get here
at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink0(Native Method)
at sun.nio.fs.WindowsNativeDispatcher.CreateSymbolicLink(WindowsNativeDispatcher.java:901)
at sun.nio.fs.WindowsFileSystemProvider.createSymbolicLink(WindowsFileSystemProvider.java:578)
at java.nio.file.Files.createSymbolicLink(Files.java:1043)
at org.eclipse.jgit.util.FileUtil.createSymLink(FileUtil.java:96)
at org.eclipse.jgit.util.FS_Win32_Java7.detectSymlinkSupport(FS_Win32_Java7.java:80)
at org.eclipse.jgit.util.FS_Win32_Java7.supportsSymlinks(FS_Win32_Java7.java:71)
at org.eclipse.jgit.internal.storage.file.FileRepository.create(FileRepository.java:306)
at org.eclipse.jgit.lib.Repository.create(Repository.java:169)
at org.netbeans.libs.git.jgit.commands.InitRepositoryCommand.run(InitRepositoryCommand.java:89)
at org.netbeans.libs.git.jgit.commands.GitCommand$1.run(GitCommand.java:80)
at org.netbeans.libs.git.jgit.commands.GitCommand$1.run(GitCommand.java:77)
at java.security.AccessController.doPrivileged(Native Method)
at org.netbeans.libs.git.jgit.commands.GitCommand.execute(GitCommand.java:77)
at org.netbeans.libs.git.GitClient.init(GitClient.java:871)
at org.netbeans.modules.git.client.GitClient$33.call(GitClient.java:574)
at org.netbeans.modules.git.client.GitClient$33.call(GitClient.java:570)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1$1.call(GitClient.java:956)
at org.netbeans.modules.git.client.GitClient$CommandInvoker$1.call(GitClient.java:979)
at org.netbeans.modules.git.FilesystemInterceptor.runWithoutExternalEvents(FilesystemInterceptor.java:496)
at org.netbeans.modules.git.Git.runWithoutExternalEvents(Git.java:282)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethodIntern(GitClient.java:989)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:916)
Caused: org.netbeans.libs.git.GitException
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:932)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.runMethod(GitClient.java:898)
at org.netbeans.modules.git.client.GitClient$CommandInvoker.access$400(GitClient.java:892)
at org.netbeans.modules.git.client.GitClient.init(GitClient.java:570)
[catch] at org.netbeans.modules.git.ui.clone.RepositoryStep$RepositoryStepProgressSupport.perform(RepositoryStep.java:323)
at org.netbeans.modules.git.client.GitProgressSupport.performIntern(GitProgressSupport.java:115)
at org.netbeans.modules.git.client.GitProgressSupport.run(GitProgressSupport.java:108)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
The stack trace shows that the code failed when trying to create a symbolic link by calling Files.createSymbolicLink(). To do that on Windows 10 you must run with Administrator rights, or you need to have the right to create a symbolic link, so the true solution to your problem is to set appropriate User Account Control (UAC). This is the case even if you created the file or directory to which you want to add a symbolic link.
If you open a Command Prompt window, create a directory and then try to add a symbolic link it will fail with the error "You do not have sufficient privilege to perform this operation", but if you do the same thing when selecting Run as Administrator before opening a Command Prompt window it works fine:
The same principles apply when creating a symbolic link in a Java application on Windows 10, and again the proper solution is to set UAC appropriately. However, there is an easy workaround solution: just as you can open a Command Prompt window as an administrator, you can also run NetBeans as an administrator:
Once you do that the java.lang.InternalError should be gone.
You can run the trivial Java application below to confirm that admin rights are needed when creating a symbolic link under Windows 10. The application fails with a FileSystemException ("A required privilege is not held by the client.") when calling Files.createSymbolicLink() from NetBeans if it is started normally, but works fine when NetBeans is Run as administrator.
public class SymLink {
public static void main(String... args) throws IOException {
String originName = "c:\\ThisIsJunk";
String targetName = originName + "SymLnk";
Path origin = Files.createDirectories(Paths.get(originName));
Path target = Paths.get(targetName);
try {
Files.delete(target);
} catch (NoSuchFileException e) {
}
try {
Path symLink = Files.createSymbolicLink(target, origin);
System.out.println("Symbolic link created: " + symLink.toString());
} catch (AccessDeniedException e) {
e.printStackTrace();
}
}
}
After having the same issue mentioned above while running in Administrator Mode, I noticed I had Netbeans running in Windows 8 Compatibility mode. Unchecking compatibility mode, I was then able to connect to the Github repository.

How to access methods from main regarding an array [duplicate]

There was error occurred in Line 14.
Exception in thread "main" java.lang.RuntimeException: Uncompilable
source code - Erroneous sym type:
Hard to find solution.
package example;
public class Num
{
public static void main(String [] args)
{
String s = "42";
try
{
s = s.concat(".5");
double d = Double.parseDouble(s);
s = Double.toString(d);
int x = (int) Math.ceil(Double.valueOf(s).doubleValue()); //Line 14
System.out.println(x);
}
catch (NumberFormatException e)
{
System.out.println("Wrong Number");
}
}
}
The code you provided runs fine on my computer.
I'm guessing you are using Netbeans and may be affected by a bug.
Try this:
Open the project properties, select the Build-Compiling, uncheck "Compile on save" and rerun the application. This will make sure all your source code becomes recompiled before running it.
Link: https://forums.netbeans.org/topic43241.html
This is a common issue which I get while working. What I do is clean and build the project. It solves the problem.
Right Click on the project name >> Clean and build
Download/install JDK major version number the same as NetBeans.
i.e. If You have NetBeans 9 version, but your JDK is version 10,then try use NetBeans 10 version... or download/install JDK 9 (the same as NetBeans).
Create new java platform for new jdk installation.
Open netbeans menubar->tools->Java Platforms->Add Platform
Specify the folder that contains the Java platform as well as the sources and Javadoc needed for debugging.
Set new java platform to your project
Right click on project ->properties->Libraries->Java Platform->select the jdk version that same as NetBeans
Select source format of your project
Right click on project ->properties->Sources->Sources/binary format->select the jdk version that same as NetBeans.
If it still gives errors like,
Exception in thread "main" java.lang.RuntimeException:
at javaapplication2.JavaApplication2.main(JavaApplication2.java:1)
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\James\AppData\Local\NetBeans\Cache\dev\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 1 second)
do as "sinclair" has mentioned above.
Open the project properties, select the Build-Compiling, uncheck "Compile on save" and rerun the application. This will make sure all your source code becomes recompiled before running it.
I received this error after I'd changed the type of a function parameter and it was the calling page that was in error - but I didn't see this until a magical Clean and Build pointed me to the actual issue!
I got this error message because I copied and pasted code without including the package name. I added the package name and it was fixed.
in my case
i have solved using import with package name and class name
like this import package.class1;
Please uncheck "Compile on save"

How to create executable (.exe) file for any platform using Sikuli-script + Java + Eclips IDE

I have create java application using sikuli-script(latest version 1.0.1).
I added the sikuli-script.jar to the Referenced Libraries (I configured using this answer Answer Link)
java code folder structure -->
Java code -->
package com.example.sikuli;
import org.sikuli.script.*;
import java.util.concurrent.TimeUnit;
public class TestSikuli {
public static void main(String[] args) {
Screen s = new Screen();
App app = new App("C:/Program Files/Mozilla Firefox/firefox.exe");//firefox path
try{
app.focus();
TimeUnit.SECONDS.sleep(2);
s.click("imgs/1391152193781.png", 0);//url bar image
s.type(null, "http://www.google.lk", 0);
s.click("imgs/1391152289812.png", 0);//click search image
}
catch(FindFailed e){
e.printStackTrace();
}
}
}
After that i set the the Run Configutrtion such as PATH and SIKULI_HOME
Next I run the code it's working properly.
Then I create .exe using launch4j and according to this site instructions --> How to Create an Executable File from Eclipse
After that i run the .exe file from command prompt then following errors occurred. Please help me.
Error -->
[error] ResourceLoaderBasic: check: libs dir is empty, has wrong content or is outdated
[action] ResourceLoaderBasic: check: Please wait! Trying to extract libs to: C:\Documents and Settings\Dell\SikuliX\libs
[error] ResourceLoaderBasic: loadLib: Fatal Error 109: not found: C:\Documents and Settings\Dell\SikuliX\libs\VisionProxy.dll
[error] Terminating SikuliX after a fatal error(109)! Sorry, but it makes no sense to continue!
If you do not have any idea about the error cause or solution, run againwith a Debug level of 3. You might paste the output to the Q&A board.
--1. when programming in Java using Sikuli, you should always use sikuli-java.jar (sikuli-ide.jar contains much stuff not needed here).
--2. Set a JVM option -Dsikuli.Debug=3 when running the exe to get more details about what's going on. I guess the problem is, that for some reason the export of the native libs does not work in the context of a launch4J exe (I did not test this yet).
--3. always use the latest version (1.1.1 in this case, still nightly but pre-final ;-) http://sikulix.com

How to run a Mac application From Java?

I tried the code below to run a stand-alone utility app I created from Apple script but, I get a No File or Directory Exists error.
I put identical copies (for testing) in the project, dist, parent directories but, it didn't help.
So, my questions are:
Is my call to run the app bad (perhaps because it's not a Windows exe)?
How to run a mac app from java?
Thanks
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
Runtime r=Runtime.getRuntime();
Process p=null;
String s="MyLineInInput.app";
try {
p = r.exec(s);
} catch (IOException ex) {
Logger.getLogger(AudioSwitcherView.class.getName()).log(Level.SEVERE, null, ex);
}
}
A Mac App Bunde is not an executable file, it's a folder with a special structure. It can be opened using the open command, passing the App Bundle path as an argument: open MyLineInInput.app.
EDIT:
Even better would be using Desktop.getDesktop().open(new File("MyLineInInput.app"));
I used the Runtime.getRuntime().exec() method with the open command mentioned in the selected answer. I didn't use Desktop.getDesktop().open() since it unwantedly opened a terminal in my case and I didn't want to create an extra File object.
Process process = Runtime.getRuntime().exec("open /System/Applications/Books.app");
Reason for adding '/System':
It seems we need to use the /System prefix for System apps. For user-installed apps, that's not required, and it can be like /Applications/Appium.app.
To answer #Pantelis Sopasakis' issue that I also faced initially -
I get the error message: java.lang.IllegalArgumentException: The file: >/Applications/Microsoft Office 2011/Microsoft\ Excel.app doesn't exist.
In this case, it could be simply due to not escaping the space characters in the path.
Environment: JDK 11 Zulu - macOS Monterey 12.2.1 - M1 Silicon

MidiUnavailableException in Java?

I'm having some trouble playing MIDI files in Java. What I get is a MidiUnavailableException (MIDI OUT transmitter not available) when I try to play it. My code is standard:
try {
midiseq = MidiSystem.getSequencer();
midiseq.open();
midiseq.setSequence(MidiSystem.getSequence(sound1));
midiseq.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
midiseq.start();
} catch (Exception e) {e.printStackTrace();}
midiseq is a Sequencer; sound1 is an InputStream.
This code works on several other computers, and even works in Eclipse and when used in a JAR file, just not when I launch it from the command prompt. I've downloaded a more stable Java midi application, and it threw the same exception.
It can't be a hardware problem because Eclipse can run it without problems, neither can it be a coding problem because this runs correctly on other computers. Even this one line of code throws this exception:
javax.sound.midi.MidiSystem.getSequencer();
Thanks in advance.
edit: My operating system is Windows Vista. Before I asked this question I've downloaded the latest JRE and JDK (1.6.0_13 I think).
edit: The code:
ClassLoader.getSystemClassLoader().loadClass("com.sun.media.sound.RealTimeSequencer");
System.out.println( "Sequencer class loaded" );// Otherwise ClassNotFoundException
prints "Sequencer class loaded."
But this code:
try{
System.out.println(javax.sound.midi.MidiSystem.getSequencer());
System.exit(0);
} catch(Exception e) {
throw new RuntimeException(e);
}
System.exit(1);
throws the MidiUnavailableException.
Also, this code:
MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
if (devices.length == 0) {
System.out.println("No MIDI devices found");
} else {
for (MidiDevice.Info dev : devices) {
System.out.println(dev);
}
}
gives me this:
Microsoft MIDI Mapper
Microsoft GS Wavetable Synth
Real Time Sequencer
Java Sound Synthesizer
First have a look at the capabilities of your system:
MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
if (devices.length == 0) {
System.out.println("No MIDI devices found");
} else {
for (MidiDevice.Info dev : devices) {
System.out.println(dev);
}
}
If there is nothing there, you might need to install soundbanks to enable the
jvm to create a software sequencer.
Also check the output of MidiSystem.getReceiver() as the dreaded MidiUnavailableException will also occur if a receiver can not be created (MidiSystem javadoc).
I expect that installing the soundbank file will give the jvm the opportunity to fall back on a synthesizer receiver, and not require hardware access anymore (which seems to fail:)
Is it possible that it has something to do with permissions? If you're running the JAR file as a different (more privileged) user than the plain command-line program, that might explain the difference. If it's not that, maybe some Java system property... I can't think of anything else that would make a difference between running the same code as a JAR file or as individual .class files.
It might help if you edit the question to provide more details about the different ways you've been running the program.
WHen launching from the command prompt makes it fail, but launching from a JAR works, I'd check if you really use the same Java version for both cases. For the Jar, check file associations in Windows Explorer, and for the commandline, check whether java -version outputs the expected version (if not, dig through your PATH variable).
Also (another shot in the dark), can you try and do a hard-shutdown on any other application that may be using sound and specifically Midi devices? I know that people get this problem on some Linuxes when another application uses Midi and doesn't release it.
When you have JMF2.1.1e installed, remove all sound.jar files which are not only installed in the JMF directory but also in the jre and jdk directories.
http://www.coderanch.com/t/274513/java/java/javax-sound-midi-compatibility-JMF says:
The problem is the file sound.jar Find it in 3 places and delete it.
C:\Program Files\JMF2.1.1e\lib\sound.jar
C:\Program Files\Java\jdk1.6.0_07\jre\lib\ext\sound.jar
C:\Program Files\Java\jre1.6.0_07\lib\ext\sound.jar
Also, remove sound.jar reference from PATH and CLASSPATH
This is an old sound.jar that messes up the new sound API in the new versions of Java.
Could you add your operating system and java version?
And post the exception; Java generally does a fair job saying whats wrong. It's just not always easy to understand :)
On my mac with java 1.5.0_16 I don't get an exception (on the command line).
The following program
public class MidiTester {
public static void main(String[] args) {
try{
System.out.println(javax.sound.midi.MidiSystem.getSequencer());
System.exit(0);
} catch(Exception e) {
throw new RuntimeException(e);
}
System.exit(1);
}
}
prints
com.sun.media.sound.RealTimeSequencer#d08633
You could check whether you have the sequencer class on the classpath:
ClassLoader.getSystemClassLoader().loadClass("com.sun.media.sound.RealTimeSequencer");
System.out.println( "Sequencer class loaded" );// Otherwise ClassNotFoundException
This would at least make it clear whether you do not have the classes (in the java accessed via the PATH), or whether it's something different like a permission problem.
Point explorer to your JRE folder (the one above the bin folder on the $PATH you are using to run the program) e.g. "C:\Program Files\Java\jre1.6.0"
Go into the \lib folder. Do you see a folder called "audio"? Does it have anything in?
If not, go to http://java.sun.com/products/java-media/sound/soundbanks.html
download any of the MIDI banks as described, and copy it into the said folder.
let us know if it works!
I've found the same problem: unable to play MIDI. But I've noticed that the problem had started when I upgrade the JDK from 1.6.0_10 to 1.6.0_13.
I tested both JDKs with the simple program:
public class MidiTester {
public static void main(String[] args) {
try{
System.out.println(javax.sound.midi.MidiSystem.getSequencer());
System.exit(0);
} catch(Exception e) {
throw new RuntimeException(e);
}
System.exit(1);
}
}
JDK 1.6.0_10 gave the result:
com.sun.media.sound.RealTimeSequencer#1bd747
JDK 1.6.0_13 gave the result:
Exception in thread "main" java.lang.RuntimeException: javax.sound.midi.MidiUnavailableException: MIDI OUT transmitter not available
at ivan.seaquest.MidiTester.main(MidiTester.java:10)
Caused by: javax.sound.midi.MidiUnavailableException: MIDI OUT transmitter not available
at com.sun.media.sound.AbstractMidiDevice.createTransmitter(AbstractMidiDevice.java:444)
at com.sun.media.sound.AbstractMidiDevice.getTransmitter(AbstractMidiDevice.java:299)
at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:451)
at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:348)
at ivan.seaquest.MidiTester.main(MidiTester.java:7)
I'm going to create a bug at Sun. I hope it helps...
I have had the same problem. The error was caused by JMF included in the classpath.

Categories