0

I would like to know what are the available classes when I import a .jar file to Matlab. I am interested in something like whos or the tab autocomplete.

First I use javaaddpath to add the relevant file to the search path. What should I do next?

NoamG
  • 137
  • 9

1 Answers1

1

I'm afraid there is no way to get tab autocomplete working for java classes, but there is a number of ways to discover the contents of a jar file and inspect classes.

  1. Using JDK, jar tf command lists files in the jar, including classes. Use javap to get more details on a particular class. There is no need to use Matlab for that - you can just use command line, but you could run the same commands from Matlab using system function if you prefer.

  2. You can browse jar archive like you do a normal zip archive, e.g. using 7zip.

  3. Simply checking that jar file contains a certain class does not necessarily mean it will work in Matlab, though. If some jar dependency is missing, or added dynamically while main jar is on static java classpath, or e.g. if jar was compiled with a later java version, classes will not be loaded (and there will be no exceptions during javaaddpath either, which can be confusing). To verify that a certain class was loaded properly, and check which jar file(s) it is located in (just in case your class is masked), use whereisjavaclassloadingfrom function, provided by Andrew Janke in this answer.

  4. You can use uiinspect FEX utility to browse methods and properties of a particular class through a convenient UI right from Matlab.

  5. You can use Reflections Library to e.g. find all classes in a given package.

Community
  • 1
  • 1
nirvana-msu
  • 3,877
  • 2
  • 19
  • 28