Matlab and Java issue - java

I messed with the version of Java that I was using in Matlab and then I had some issues, so I tried to delete Matlab and all versions of Java from my machine then reinstall Matlab. According to,
http://www.mathworks.com/matlabcentral/answers/130359-how-do-i-change-the-java-virtual-machine-jvm-that-matlab-is-using-on-windows
Matlab already has java in it, so I assumed that the fresh install of Matlab would fix the issue. But it did not and I ended up having to install Java and point to it as per the article above just to get Matlab working with Java again.
The issues are these:
When I start up Matlab, I get
Sometimes it spools red errors and I have to shut Matlab off
I loose a lot of the interactive features, for instance; I cannot click on the folder ribbon to move through the folders as:
3.b also, sometimes I cannot resize windows.
So, I lost some functionality. How can I run the version of Java that ships with the student version of Matlab?
Thanks!!

I point the system MATLAB_JAVA variable to:
C:\Program Files\MATLAB\R2015a\sys\java\jre\win64\jre
Which is the original java version that MATLAB was shipped with. For some reason, the new java is buggy with the new matlab

Related

Running standard exe from java .jar file on clients computers

I have a program that I want to run as an exe on a clients computer. After I made my program in Java I used Jsmooth to create the exe. The program runs perfectly fine from my own local computer, but when I try running the same program on another computer the program prompts me to install Java. After installing Java, the program STILL wants me to install Java. I thought it might be different versions of Java, but I compiled the Jar with the most LTS of Java, and my JRE was on the most recent version. What should I do?
JVMs are quite large. Out of the box, JSmooth therefore doesn't include one. I think you can ask it (I'm recalling exe4j perhaps, a different tool that does the same thing as jsmooth), by stating which path contains one relative to the executable. You cannot fold it straight into the exe, though. It'll then be an installation process where you end up with:
C:\Program Files\AnthonysAwesomeApp\Anthony.exe
C:\Program Files\AnthonysAwesomeApp\jre\lib\rt.jar
C:\Program Files\AnthonysAwesomeApp\jre\bin\java.exe
... and the other 5000 files of a JRE installation
Where 'Anthony.exe' is made by JSmooth, and you told JSmooth that it should use the JRE found in location ".\jre".
That should probably still work.
The more general problem is that the entire deployment model is more or less obsolete; JREs do not exist anymore, at least, oracle/team openjdk has ceased producing them and has ceased mentioning the very concept, but some third party deployers such as Azul still produce them. Java1.8 is the last version that can truly be said to have had the concept of a JRE.
A JDK is a superset of a JRE (It has everything a JRE has, and more), and JDKs still exist, so you should just be able to ship an entire JDK.
The new model is jlink, modules, and treeshaking, and it doesn't feel like any of the exe maker projects such as JSmooth have been updated for it. In general, java is used a ton on servers, but java on the desktop is not observed that much. If you want to delve into those - you have a lot of reading to do, and the experience is not as smooth (heh) as JSmooth.

How do portable Java programs run the JVM from a subdirectory next to the binary?

I have been programming in Java for several months, one of the tools I use is Eclipse, which seems to be able to run standalone from any local Java installation by having the JDK/JRE in a directory next to the main binary.
I have run it from my USB-drive in computers without any Java Runtime/Framework/other... And it has been able to open itself, understand the Java code, compile it, and run it without any problem.
So, the question is How do they do it?. At least in the Windows version (Did not try in the Linux version but I think it might work as well).
See following threads.
https://www.eclipse.org/forums/index.php/t/264351/
How does Eclipse compile classes with only a JRE?
Do I need to install Java SDK if I have eclipse
The eclipse.ini file will point to the local vm location
https://wiki.eclipse.org/Eclipse.ini

Does java use the registry to locate its default jar files?

Target Environment
Windows 7 (6.1)
Java 1.8.0_121 64bit
I recently created a minimal java environment consisting of just the single file java.exe in a newly created, empty directory and successfully ran a simple HelloWorld.class file simply by copying it to the same directory and typing:
.\java HelloWorld
I found this kind of surprising, and wondered if maybe because the version of java I was using (jre 1.8.0_72) had been installed from an .exe file whether there was something in the Windows registry telling java.exe where to find rt.jar and such.
Running the java control panel, you can certainly see java 1.8.0_72 is in there:
I if I used a java version which was NOT installed (i.e. a standalone java version) would I get a different result?
Well, before trying a stand-alone version I think I'll try a computer having NO java on it at all. Same exact set up as before.
Found part of the answer on my wife's Windows 10 computer (which has no java on it):
Clearly, I should copy java.dll somewhere. Think I'll put it in the same directory as everything else (i.e. the same one as the java.exe), and try that.
Nope. Same as before.
So clearly java is looking in the registry to find its .dll.
I've downloaded jre-8u121-windows-x64.tar.gz. I'm going to try the same experiment with that.
Tried the same experiment with java from the tarball above. Exact same symptom. Cannot find java.dll.
Having done a little reading, I see that Embedded Java SE has a way to create custom deployments of java. There appears to be no official analogous mechanism for Java SE for Windows.
Doing a little more reading, I see that there is a mechanism called the Invocation API which can be used to run java, bypassing java.exe. This might be something to try. Might also be time to start surfing the HOTSPOT code.
More on the Invocation API here: http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html
An intriguing note I also ran into during my reading said this:
Private vs. public JRE - Installing the JDK installs a private Java SE Runtime Environment (JRE) and optionally a public copy. The private JRE is required to run the tools included with the JDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\jdk1.6.0\jre) whose location is known only to the JDK.
I read this here: http://www.oracle.com/technetwork/java/javase/install-windows-142126.html
You might try this experiment with THAT jre.
Today I also face same problem .and I found the solution for this go-to your JDK bin copy path from there and peast this path to environment variable path and the priority should be first that mean it should be peast in starting of all path.

Portable JDK for Minecraft modding

this is probably going to spark a lot of 'Duplicate of ...' but I really need to know if this is do-able.
I'm currently attempting to make mods for Minecraft with the Minecraft Coders Pack and Eclipse Java EE.
I am not an admin on my machine so I can't get JDK which MCP needs.
All I need basically is the files from JDK, I'm not having problems with setting JAVA_HOME and PATH as I can set those dirs manually in the de-compiler.
I need JDK 6
I have done this myself because I was in the same position. I tried copying the JDK as well, but that didn't work, could be a mistake on my part.
I am using OpneJDK now, and that works perfectly with intelij-idea, I'm sure it works with Eclipse as well.
http://openjdk.java.net/

What packaging tool should I use for a Mac/Windows Java app?

I have a Java desktop app that runs on both the MacOS and Windows.
I understand that I cannot have one distribution for each, which is not a requirement.
I need to know what tool or tools is best to use when delivering a Java app for each.
The tool should install prerequisites (in this case, Java and some JARs) and look native to the respective operating system.
As for OS X's java situation:
Currently, JDK 6 is bundled in the OS.
Presumably, the next version of the OS will still include JDK 6.
It's publicly stated that the OS will have a well-defined place to install multiple copies of Java runtimes, a public interface choosing which of the Java version, etc. See here.
Apple started contributing back its own code to the open JDK community, so JDK 7 should be available as a separate download, see here. 
So, you're not expected to include Java runtime itself into your Java app even then. You're not supposed to install Java in a ramdom place on a filesystem, for example.
As for how you should deploy java apps on OS X:
Double-clicking jar just works.
However, that won't be pretty, because you would only have a generic Java icon in the Dock. You don't want that.
You should use Jar Bundler to make it an honest OS X app. On Mac, it comes with XCode. See the documentation here. You can do that on a non-Mac machine too, using this open-source project.
On Windows, I would recommend either JSmooth or WinRun4J.
On a Mac, the situation is a bit more complex (as the comments point out), but just distributing an executable JAR is probably good enough for now.

Categories