mad
mad

Reputation: 2789

Can't import java libraries with matlab

I am running a matlab function which uses the LinkedList class from java. But when I run the script I get the following error:

Undefined function or variable 'LinkedList'.

 Error in (line 6)
 Q = LinkedList();

In the beggining of the code I do the following

import java.util.LinkedList
Q = LinkedList();

I think matlab is not founding java library files. Java is installed on my computer as the following command on my linux machine shows:

update-java-alternatives -l
java-1.7.0-openjdk-amd64 1051 /usr/lib/jvm/java-1.7.0-openjdk-amd64

I am using the command line matlab.

What I missed here?

Upvotes: 0

Views: 250

Answers (1)

Daniel
Daniel

Reputation: 36720

Matlab 2012a is bundled with an Java 6 JRE. Unless you require a newer Java (which does not seem to be the case) I would strongly recommend to use this java version. To make Java available:

  • Check your launcher starting Matlab in Command Line. Make sure -nojvm ist not set.
  • Make sure java is executable, java is located in the matlab directory matlab/sys/java/jre/glnxa64
  • Try using a full desktop matlab if both previous steps don't help. The desktop requires java, here you might get some useful error message.
  • The error might also be cased by an invalid installation process (e.g. copying /moving matlab without setting the environment), for example the environment variable MATLAB_JAVA might be missing. If this is the case, reinstall matlab with the official installer.

Upvotes: 2

Related Questions