Matlab compiler sdk runtime - matlab

I have compiled a Matlab algorithm to a java.jar file and successfully run the same algorithm in java.
to use the matlab function in java, i imported the generated jar file and also the
javabuilder.jar.
now what is :
javabuilder.jar ?
Also it is possible to choose at compilation settings between
Runtime downloaded from web
and
Runtime included in package
I set Runtime downloaded from web and included only the two jar files to my project and could run the algorithm.
Where is the Matlab runtime necessary? and can i just use my Jar files also on a linux computer?

The javabuilder. jar contains the wrapper functions to communicate with the matlab runtime.
The matlab runtime is written in c++ and has to be installed on the system where the javabuilder + matlab function jar is used.
The runtime installer is included in the package file that is created by matlab to download the runtime from web or can be included with the package.

Related

JNA finds library running in Eclipse but not when a built JAR file

I am writing a program which needs to use a .dll file. When my program starts up, the following code is executed:
public static void main(String[] args)
{
String dLLURL = "C:/Program Files (x86)/Location of DLL";
System.setProperty("jna.library.path", dLLURL);
System.setProperty("jna.debug_load", "true");
System.setProperty("jna.debug_load.jna", "true");
Application.launch(args);
}
I then execute
DllInterface dllinterface = (DllInterface) Native.loadLibrary( "dllName.dll", DllInterface.class);
...which loads the correct dll and allows me to use it. JNA outputs the following (this time using the actual name/path of the DLL):
Trying (via loadLibrary) jnidispatch
Looking in classpath from sun.misc.Launcher$AppClassLoader#e2f2a for /com/sun/jna/win32-x86/jnidispatch.dll
Found library resource at jar:file:/C:/Users/bengs_000/Downloads/jna.jar!/com/sun/jna/win32-x86/jnidispatch.dll
Trying C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna2314341730536889248.dll
Found jnidispatch at C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna2314341730536889248.dll
Looking for library 'RailDriver.dll'
Adding paths from jna.library.path: C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins
Trying C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
Found library 'RailDriver.dll' at C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
This is what happens when I run the program in Eclipse IDE. It works just fine!
However, when I build/run the program as a .jar, the application says the DLL cannot be found (despite looking in the correct location) and returns the following message:
Trying (via loadLibrary) jnidispatch
Looking in classpath from java.net.URLClassLoader#677327b6 for /com/sun/jna/win32-x86-64/jnidispatch.dll
Found library resource at jar:rsrc:jna.jar!/com/sun/jna/win32-x86-64/jnidispatch.dll
Trying C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna8530559464473818762.dll
Found jnidispatch at C:\Users\BENGS_~1\AppData\Local\Temp\jna-792348840\jna8530559464473818762.dll
Looking for library 'RailDriver.dll'
Adding paths from jna.library.path: C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins
Trying C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
Adding system paths: []
Trying C:\Program Files (x86)\Steam\SteamApps\common\RailWorks\plugins\RailDriver.dll
Looking for lib- prefix
Trying libRailDriver.dll
Looking in classpath from java.net.URLClassLoader#677327b6 for RailDriver.dll
There was an error finding your raildriver.dll file
As you can see, exactly the same path is taken to find the .dll file yet it works in Eclipse and not as a compiled .jar file!
Would you please be able to help me identify the problem? One thing to note is that the .dll file is stored within the 32bit section of Program Files, and my computer is 64bit. I am using Java 32bit to compile and run the program in Eclipse. Surely it should build the .jar with Java 32bit right?
I have found a solution!
The Background
I knew that the problem was related to the .dll I wanted to use being 32bit, and my computer being 64bit. In the Eclipse IDE, I was running the app using Java 32bit (I knew I should to this to ensure compatibility).
When running the .jar file, Java was defaulting to the 64bit version; different to how I was testing it in Eclipse.
The Solution
To force the user to use Java 32bit, you need to bundle the .jar into an .exe file. I used Launch4J to do this. There's a parameter in Launch4j which allows you to specify which systems of Java to use. This is located under the JRE tab in the "Search Options" section. By changing it to "32-bit only", the .jar file is launched under Java 32-bit, thus alleviating the problem!
I hope this might help some one!

Exporting Executable jar file that uses opencv

While exporting in eclipse I choose "Package required libraries into generated jar".
The jar file works only in my machine. However, when I test it on other machine it gives this Exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681)
at java.lang.Runtime.loadLibrary0(Runtime.java:840)
at java.lang.System.loadLibrary(System.java:1047)
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load(Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
at mains.<clinit>(mains.java:25)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Short answer
You must install OpenCV (as mentioned in JavaCV requirements) and JavaCV on the system in order to use JavaCV. As you probably installed them for development on your computer the application work, but the other machine probably has not them installed and thus the jar does'nt work.
Long answer
The problem is not the JavaCV library, which appears to be correctly included into your jar as shown by the lines:
at com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
at com.googlecode.javacpp.Loader.load(Loader.java:489)
at com.googlecode.javacpp.Loader.load(Loader.java:431)
at com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
The fact is JavaCV is build on top of OpenCV. OpenCV being a C++ library, the only way to use it from Java is to use JNI calls.
JNI require two components:
A java library (usually with extension *.jar) containing java method that calls native library
A native library (usually with extension *.so for linux or *.dll for windows) that "do the work", in this case that "use OpenCV library"
The first one is provided by JavaCV and included into your jar application. The second one is system dependent (Os, architecture, ...) and must be into the java library path.
This is the actual error: it can not find libjniopencv_core.so into java.library.path. The jniopencv_core library is provided by JavaCV too but is installed somewhere on the system (/usr/lib/ for instance) and thus not included into the final jar.
Even if you find a way to include it into the final application, this library will need to use OpenCV libraries which are not installed on the system too. To summarize the needs:
JavaCV java library, that will call (with JNI):
JavaCV native library, that will use:
OpenCV libraries, that will really do the work.
Without one of this point the application will not work. Thus OpenCV and JavaCV must be installed into the system.

Simbad requires Java 3D

Context:
MS Windows 8,
jre7 preinstalled by MS Windows setup,
MS Windows PATH environment variable has set to JRE7 bin folder - C:\Program Files (x86)\Java\jre7\bin,
simbad-1.4.jar is downloaded into a local folder.
Use cases:
simbad-1.4.jar is run by command line
java -jar simbad-1.4.jar
or by just double-clicking on simbad-1.4.jar
In both cases
Simbad requires Java 3D
error message box appears.
Yes, I know, setting-up Java 3D should probably fix the issue but I'd like to just deliver/setup Java 3D together with/in a subfolder to simbad-1.4.jar IOW to not install Java 3D into a standard C:\Program Files (x86)\Java\Java3D location.
Please advise how can I setup Java 3D packaged together with simbad-1.4.jar, or answer a more general question:
How to deploy a Java client application, which uses Java 3D, packaged together with Java 3D library?
P.S. I know about and I have used -classpath option to successfully run other sample java client apps' .jar(s) I have made exported by using Eclipse but they haven't used nor Java 3D nor simbad-1.4.
I'm using a slightly different environment (Win7-64bit, JDK 1.7), but this should work for your environment also.
download java3d .zip package from https://java3d.java.net/binary-builds.html
unzip the downloaded file, and there's is another zip file named "j3d-jre.zip"
unzip 'j3d-jre.zip' in a directory you want to package together.
place simbad jar file in that directory.
create a DOS batch file with these lines in it:
#echo off
set CLASSPATH=.;.\lib\ext\j3dcore.jar;.\lib\ext\j3dutils.jar;.\lib\ext\vecmath.jar;.\simbad-1.4.jar
set PATH=%PATH%;.\bin
java -classpath %CLASSPATH% simbad.gui.Simbad
Hope this helps.

How to create install file for a Web Dynamic project Java EE

What's the best way to create/generate a setup file (.EXE) for a web dynamic project from Eclipse ?
the project must be installed after installing tomcat & SqlCE silently, since it depends on them both to work
thanks
There are many custom exe packers are available on web.
Just google for some "jar to exe" or "setup maker" type things you would definitely find something.
Something like this.
Java has no support for exe files. Exe files are specific to Windows platform while Java is intented to be platform independent.
Eclipse for Java doesn't offer builtin facilities to generate exe files since they have absolutely nothing to do with Java. Java's way is an executabele JAR file. You could create an executabele JAR file wherein you do the installing job in a main() method. Once you have the main() method finished, Eclipse can autogenerate the JAR by the Runnable JAR wizard.
If you really want an exe file, you'd need to write a custom one using C++ or C# (at least, the same language as Windows is written in and natively supports). It should then do basically the same as what you would do in the Java's main() method.

Package Jython app as JAR in Netbeans

We are currently considering using Netbeans to develop a Jython application and I am in the process of evaluating Netbeans' features.
It appears that creating a Jython application is trivial in Netbeans once the Python and Jython modules are installed. Yet I couldn't find a feature which would let we wrap my Jython app as a JAR file with all its dependencies. Is this possible with Netbeans or with some other IDE or do I need to do this kind of packaging by hand?
Have you tried jump
http://pypi.python.org/pypi/jump/0.9.7.4
jump Homepage
Features :
Distributing Jython applications into a single, independent JAR file.
Distributing Jython libraries into a single JAR file. [New in v0.9.5]
Distributing native Mac OS X application bundles, Windows .exe executables, WAR files for Python WSGI applications. [New in v0.9.5]
Distributing Java Only applications. [New in v0.9.6]
Creating build.xml file for ant. [New in v0.9.7]
Supporting Java source code and third-party JAR files.
Supporting Java Native Interface files for distributing JAR files. [New in v0.9.5]
Starting the created distribution from either Jython or Java code.
Including specified resource files in the final distribution. [New in v0.9.6]
Packaging only required Python packages into the final distribution automatically, which means you don't have to worry about using Python third-party libraries as long as they can be found in your sys.path.
Importing specified Python packages explicitly. [New in v0.9.5]
All Python modules included in the final distribution are compiled to $py.class files, which means your source code is not public.
Integrated easy use Jython factory. [New in v0.9.7]
Quick-start Guide
There is also a info in the jython-wiki (not jump related)
In brief:
Jar file: run jump jar --main-entry-point=file:main (where file is the name of the Python script file and main is the application's main method/entry point
WAR file: run jump war --main-entry-point=file:main --war-wsgi-handler=...
The various options available for jump can be shown by outputting help/usage information: run jump --help.