RNetLogo works on R3.1.1.0? - java

When I try to launch the RNetLogo from R using the function NLStart(). I get messages about java and the GUI does not open. I am using MacOsX 10.9.5 64-bit, NetLogo 5.1.0, and R 3.1.1.
> library(rJava)
> library(RNetLogo)
> nl.path <- "/Applications/NetLogo\ 5.1.0/NetLogo\ 5.1.0.app"
> NLStart(nl.path, nl.version=5, gui=FALSE)
java.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
Caused by: java.lang.ClassNotFoundException
at RJavaClassLoader.findClass(RJavaClassLoader.java:383)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more
After that I try with "JGR and Deducer and deducer extras”.
The code and errors are:
> install.packages(c("JGR","Deducer","DeducerExtras”))
> Sys.setenv(NOAWT=1)
> library(JGR)
> Sys.unsetenv("NOAWT")
> JGR()
When start JGR the code is:
Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots
starting httpd help server ... done
Loading required package: RNetLogo
Loading required package: DeducerExtras
Loading required package: Deducer
Loading required package: ggplot2
Use suppressPackageStartupMessages to eliminate package startup messages.
Loading required package: car
Loading required package: MASS
Attaching package: ‘Deducer’
Loading required package: irr
Loading required package: lpSolve
> nl.path<-"/users/Pabolo/Applications/NetLogo\ 5.1.0/NetLogo.jar"
> NLStart(nl.path)
Error on setwd(nl.path) : you can not change the working directory.
With nl.path be the path to the app dir.
There are some errors.
I running all these over JGR().
> nl.path<-"/Applications/NetLogo\ 5.1.0"
> NLStart(nl.path)
Warning: ch.randelshofer.quaqua.util.OSXPreferences failed to load /Users/Pabolo/Library/Preferences/.GlobalPreferences.plist
java.io.IOException: parseReal: unsupported byte count:128
at ch.randelshofer.quaqua.util.BinaryPListParser.parseReal(BinaryPListParser.java:703)
at ch.randelshofer.quaqua.util.BinaryPListParser.parseObjectTable(BinaryPListParser.java:424)
at ch.randelshofer.quaqua.util.BinaryPListParser.parse(BinaryPListParser.java:315)
at ch.randelshofer.quaqua.osx.OSXPreferences.readPList(OSXPreferences.java:176)
at ch.randelshofer.quaqua.osx.OSXPreferences.updateCache(OSXPreferences.java:99)
at ch.randelshofer.quaqua.osx.OSXPreferences.ensureCached(OSXPreferences.java:90)
at ch.randelshofer.quaqua.osx.OSXPreferences.get(OSXPreferences.java:79)
at ch.randelshofer.quaqua.osx.OSXPreferences.getString(OSXPreferences.java:45)
at ch.randelshofer.quaqua.BasicQuaquaLookAndFeel.initSystemColorDefaults(BasicQuaquaLookAndFeel.java:151)
at ch.randelshofer.quaqua.leopard.Quaqua15LeopardLookAndFeel.initSystemColorDefaults(Quaqua15LeopardLookAndFeel.java:208)
at ch.randelshofer.quaqua.BasicQuaquaLookAndFeel.getDefaults(BasicQuaquaLookAndFeel.java:76)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:520)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:564)
at org.nlogo.swing.Utils.setSystemLookAndFeel(Utils.java:41)
at org.nlogo.app.App.<init>(App.scala:302)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:147)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:332)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:272)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:354)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:692)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:646)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:671)
at org.nlogo.app.App$.main(App.scala:140)
at org.nlogo.app.App.main(App.scala)
at nlcon.NLink_v5.<init>(NLink_v5.java:96)
at org.rosuda.JRI.Rengine.rniRunMainLoop(Native Method)
at org.rosuda.JRI.Rengine.run(Rengine.java:640)
unable to find translation for: edit.viewSettings.2D.frameRate in GUI_Strings for locale: es
unable to find translation for: edit.viewSettings.2D.frameRate.info in GUI_Strings for locale: es
>

You have to change your path to: nl.path <- "/Applications/NetLogo 5.3/app".
They have changed the directory structure so that the netlogo jar file is now in an 'app' subdirectory.
Source: https://stackoverflow.com/a/34837036/468305
Hope that helps, it worked for me.

It says you can not change your working directory. Maybe start a new session. Also one of your backslashes is going the wrong way.
To find your NetLogo path try file.choose() and then navigate to the NetLogo Jar file. Then when you open the path to file will show in R studios console. Copy the file path into the NLStart command which should look something like below.
file.choose()
NLStart("C:\\Program Files\\NetLogo 6.2.0\\app", gui = TRUE, nl.jarname = "netlogo-6.2.0.jar")
Finally, make sure your Java, NetLogo and R are all running on 64 bit (works for me) or 32 bit but try not to mix. Finally try and run code directly from R GUI instead of RStudio. This helped the first time I opened Netlogo with R.
I have a youtube video (https://www.youtube.com/watch?v=zWMdaTEPTOc) explaining how to open NetLogo from R and all my functional code (August 2021) can be found here.

Related

MysqldResource isn't working with MacOS Catalina

Since upgrading my os to Mac Catalina,
I'm getting the following error when trying to run the following:
MysqldResource mysqldResource = new MysqldResource(uri); // Uri - temp db dir
mysqldResource.start("embedded-mysqld-thread-" + System.currentTimeMillis(), databaseOptions);
Looks like the source of the problem is with the dependency "mysql-connector-mxj-db-files" having binary files in 32bit format, while catalina stopped supporting it.
This is the error I'm getting:
Exception in thread "embedded-mysqld-thread-1574931580040" com.mysql.management.util.WrappedException: java.io.IOException: Cannot run program "/private/var/folders/l5/4ywgvbbj1kvgvrwxzp6dz82c0000gn/T/test_db_24166997810717/bin/mysqld": error=86, Bad CPU type in executable
at com.mysql.management.util.Exceptions.toRuntime(Exceptions.java:55)
at com.mysql.management.util.Exceptions$Block.exec(Exceptions.java:89)
at com.mysql.management.util.RuntimeI$Default.exec(RuntimeI.java:180)
at com.mysql.management.util.Shell$Default.run(Shell.java:140)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Cannot run program "/private/var/folders/l5/4ywgvbbj1kvgvrwxzp6dz82c0000gn/T/test_db_24166997810717/bin/mysqld": error=86, Bad CPU type in executable
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at com.mysql.management.util.RuntimeI$Default$1.inner(RuntimeI.java:177)
at com.mysql.management.util.Exceptions$Block.exec(Exceptions.java:86)
... 3 more
Caused by: java.io.IOException: error=86, Bad CPU type in executable
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 6 more
Does anyone know of an alternative to mysql-connector-java or knows of a way to run the existing dependency on Mac OS Catalina?
For anyone who has the same issue on MacOS Catalina, you can follow the README.md in my repo (https://github.com/pengyue/mysql-connector-mxj-mac-os-catalina), which has the 64 bits executables for MacOS Catalina, and this improved connector works on Catalina.
To explain what I have done:
Download the 64 bits executables from MySQL to the folder 5-5-9
Add the platform mapping for 64 bits MacOS in platform-map.properties
Create a jar by using jar cvf mysql-connector-mxj-db-files-5.0.12.jar .
Replace the jar in your mvn settings folder ~/.m2/repository/mysql/mysql-connector-mxj-db-files/5.0.12/ with the jar you just created.
This solution works fine for my projects, Unfortunately I could not find a github for the mysql-connector-mxj, as it is deprecated and not maintainable anymore.
The other option is to use wix-embedded-mysql(https://github.com/wix/wix-embedded-mysql) instead of mysql-connector-mxj, but this probably requires some code changes in your projects.

Why am I only able to successfully load dynamic linking libraries using "-Djava.library.path=" in Linux but not Windows

I am using a library that requires that I load load dynamic linking libraries. My source code that uses these libraries is identical, the only difference is the operating system that I am using and which version of the library (Windows-64 version or Linux-64 version) that I am using. The library I am using provides 1 set for Windows ".dll" files and 1 set for Linux ".so" files, each in its own folder. To load the Linux ".so" libraries, I do
"-Djava.library.path=/home/johnmichaelreed/Desktop/Dropbox/Moved_Netbeans_Projects/Crazy_Client/Libjitsi_linux_64/lib/native/linux-64"
in the VM options and everything works.
Then, when I copy and paste the directory where the Windows ".dll" native libraries are into the VM options, I get rid of the Linux libraries path and insert:
-Djava.library.path=C:\Users\JohnReedLOL\Desktop\Dropbox\Moved_Netbeans_Projects\Crazy_Client\Libjitsi_windows_64\lib\windows_native\windows-64
I then change the library JAR files to the ones that came with the Windows version of the Library and I run the program and I get this error:
SEVERE: Failed to register custom Renderer org.jitsi.impl.neomedia.jmfext.media.renderer.video.JAWTRenderer with JMF.
java.lang.UnsatisfiedLinkError: C:\Users\JohnReedLOL\Desktop\Crazy_Client\Libjitsi_windows_64\lib\windows_native\windows-64\jnawtrenderer.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1855)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.jitsi.impl.neomedia.jmfext.media.renderer.video.JAWTRenderer.<clinit>(JAWTRenderer.java:90)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at org.jitsi.impl.neomedia.device.DeviceConfiguration.registerCustomRenderers(DeviceConfiguration.java:1034)
at org.jitsi.impl.neomedia.device.DeviceConfiguration.<init>(DeviceConfiguration.java:355)
at org.jitsi.impl.neomedia.MediaServiceImpl.<init>(MediaServiceImpl.java:150)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:438)
at org.jitsi.impl.libjitsi.LibJitsiImpl.getService(LibJitsiImpl.java:142)
at org.jitsi.service.libjitsi.LibJitsi.invokeGetServiceOnImpl(LibJitsi.java:163)
at org.jitsi.service.libjitsi.LibJitsi.getMediaService(LibJitsi.java:115)
at outermost_crazy.Libjitsi_Main.<init>(Libjitsi_Main.java:124)
at outermost_crazy.Libjitsi_Main.main(Libjitsi_Main.java:827)
The weird thing is I am 100% sure that the native library path is the right place because when I print it using System.getProperty("java.library.path"), I get the folder:
C:\Users\JohnReedLOL\Desktop\Dropbox\Moved_Netbeans_Projects\Crazy_Client\Libjitsi_windows_64\lib\windows_native\windows-64
^ This folder definitely has all 12 .dll files ^. The library JAR files that I am using are the ones the ones that came with these 12 ".dll" files, not the ones that came with the Linux ".so" files, so I am pretty sure that I am using the right JAR files. Why this is error only happening on Windows with the .dll files, but not on Linux with the .so files?
Dependency Walker opening of jnawtrenderer.dll:

Java SQLite org.sqlite.JDBC classpath broken?

I stumbled upon a weird error while using JDBC sqlite with org.sqlite.JDBC
my code compiles and runs fine on Windows.
But when I tried moving it to Ubuntu it started showing this:
Exception in thread "main" java.lang.ClassNotFoundException: org.sqlite.JDBC
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at mall.SQLiteJDBC.<init>(SQLiteJDBC.java:27)
at mall.AllegroReader.<init>(AllegroReader.java:33)
at mall.Mall.main(Mall.java:31)
I'm running it with java -classpath "sqlite-jdbc-3.7.2.jar" -jar Mall.jar" and java -classpath "sqlite-jdbc4-3.8.2-SNAPSHOT.jar" -jar Mall.jar
with both versions in the same directory as my jar and I've tried a dozen different options specifying classpath and it behaves exactly the same. I tried openjdk and oracle jdk.
I tried rebuilding it on Ubuntu, changing ant .xmls, changing paths, etc.
I have no idea what is going on. Pls help.
Here is what happens inside my dist directory:
work1#workwork:/var/www/mall/dist$ ls
mall.db Mall.jar Mall.jar.old sqlite-jdbc-3.8.4.3-SNAPSHOT.jar
work1#workwork:/var/www/mall/dist$ java -classpath "sqlite-jdbc-3.8.4.3-SNAPSHOT.jar:Mall.jar" Mall
Error: Could not find or load main class Mall
The classpath is ignored when you use -jar.
You have to either include the dependencies in the jar (or at least have the jar manifest point to them), or run it with -classpath sqlite.jar:Mall.jar the.main.class.
Error: Could not find or load main class Mall.main. all files are there,
my main class comes from Mall.java and is in mall package which
compiles to Mall.jar
So the correct command line is:
java -classpath "sqlite-jdbc-3.8.4.3-SNAPSHOT.jar:Mall.jar" mall.Mall
OP findings
to view the classes in jar use jar tf Mall.jar - from this I got mall/Mall.class meaning my class containing main was mall.Mall
it showed
mall/Mall.class
so I should have used mall.Mall as the class to run (instead of pulling my hair)
After spending over 6 hours total with many failed attempts at running "portable" jar package using classpath and whatnot, after having tried OneJar and jarjar to no avail (ended up with Class file too large!) I decided to write the offending piece of code in PHP.
It proved to be more portable than Java in my case.

Unity-Android _ CommandInvokationFailure: Unable to convert classes into dex format

i'm using Windows 7, jdk 1.8.0 (64bit), jre 8 (64bit), Unity Pro 4.3.4f1 and Android SDK 22.6.1
All are updated softwares.
All works fine but when i use StartApp sdk, this error comes. No extra plugin is used, only the SDK provided by the StartApp ad.
Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:\Program Files\Java\jdk1.8.0\bin\java.exe -Xmx1024M -Dcom.android.sdkmanager.toolsdir="D:/android-sdks\tools" -Dfile.encoding=UTF8 -jar "C:/Program Files (x86)/Unity/Editor/Data/BuildTargetTools/AndroidPlayer\sdktools.jar" -
stderr[
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/unity3d/player/a$1;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
at com.android.dx.command.dexer.Main.processClass(Main.java:685)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpener.java:229)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:158)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at SDKMain.main(SDKMain.java:129)
1 error; aborting
]
I already tried JAVA_OPT and JAVA_HOME solutions. But still couldn't solved
I ran into this using IntelliJ 13.1.4, JDK 1.6 but I would guess that this is caused by the same thing on any other IDE -> classes.jar is referenced/included more than once.
Check and make sure that the classes.jar you added to the project (from Unity\Editor\Data\PlaybackEngines\androidplayer\bin\classes.jar) isn't referenced/included more than once. If you go into File->Project Structure:
There should only be one "classes" under libraries.
There should be NO reference to classes under Artifacts (Artifacts is used to create the plugin .jar file.)
Check out this related answer ->
https://stackoverflow.com/a/8437996/3464367
My issue was actually related to having duplicate files. Well not really duplicates, but I had 2 adMob sdk packages (different versions), that were getting into conflict. After deleting the older one, everything was fixed. Are you using any 3rd party SDK's or something similar, if so, try removing them if possible and see if the issue persists. Try to find out which part of the code is causing this to happen. You could ultimately try to compile an empty project just for testing.
Today I solved similar problem of Error building Player: CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details. with adding .jar file into Plugins\Android\
I got different kind of errors:
Caused by: com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000 ...
Caused by: com.android.dx.cf.iface.ParseException: class name (ht/stringing/test) does not match path (src/ht/stringing/test.class)
My result working solution was similar to this:
Code lives here:
verysimple\src\ht\stringing\test.java
I do:
> javac -classpath "c:\Android\sdk\platforms\android-15" ht\stringing\test.java
> jar cvf ..\dist\verysimple.jar ht\stringing\test.class
> copy ..\dist\verysimple.jar c:\ExUnityApp\Assets\Plugins\Android
Don't forget to compare your 'Minimum Api Level' in Player Setting. For me it was Android 4.0.3 ... (15)

java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)

I wrote a Puppet to install Play 2.1.1 on Virtual Machine running CentOS 6.2.
The Puppet executed the following two commands:
/usr/bin/wget http://downloads.typesafe.com/play/2.1.1/play-2.1.1.zip
/usr/bin/unzip play-2.1.1.zip
When I run play command inside the package, it shows the following error message:
java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:209)
at java.io.FileOutputStream.<init>(FileOutputStream.java:160)
at java.io.FileWriter.<init>(FileWriter.java:90)
at xsbt.boot.Update.<init>(Checks.java:51)
at xsbt.boot.Launch.update(Launch.scala:275)
at xsbt.boot.Launch$$anonfun$jnaLoader$1.apply(Launch.scala:120)
at scala.Option.getOrElse(Option.scala:108)
at xsbt.boot.Launch.jnaLoader$2f324eef(Launch.scala:115)
at xsbt.boot.Launch.<init>(Launch.scala:94)
at xsbt.boot.Launcher$.apply(Launch.scala:290)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:31)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
Error during sbt execution: java.io.FileNotFoundException: ~/play-2.1.1/framework/sbt/boot/update.log (No such file or directory)
I didn't change a single line of code in the play-2.1.1 directory. I googled around for the error message, but did not find any useful answer. Could anyone point out what is the problem?
If the file does not exist and cannot be created,FileOutputStream will raise a FileNotFoundException (yes, this seems weird, but see the javadoc).
This error probably means that the user that started play does not have the proper permissions to create ~/play-2.1.1/framework/sbt/boot/update.log or its parent directories.

Categories

Resources