List available java packages
22 views (last 30 days)
Show older comments
I added a set of java classes by adding a *.jar file to the Matlab javaclasspath (by using "javaaddpath").
For some reason I can not access any of the classes or methods:
obj = javaObject("package.name.Constructor");
Results in "No class XX can be located on the Java class path" and
methodsview('TopPackageName')
gives "No class TopPackageName can be located or no methods for class".
I'm sure that there is no typo, particularly in the name of the ".jar file since Matlab throws a warning if the file does not exist.
Is there a way to check which classes are availible in Matlab? I'm looking for something like "methodsview", just not for methods but for classes such that I can at least identify if anything got imported or not.
The *.jar file itself was created by me from code which is verified to work. However, I only got the code files but not the project settings of that java project. Is there a way to screw up the generation of the *.jar file? I already unpacked it with 7zip, the folder which I obtain as a result contains all the expected class files, some IML file and a META-INF folder containing a MANIFEST.MF file. Unfortunately I don't now a lot about java. I was just given a bunch of *.java code files and have to make it run somehow.
0 Comments
Answers (1)
patrick1704
on 15 Jul 2022
Hi there,
you can get a list of jar-files known to Matlab by executing: Return Java class path or specify dynamic path - MATLAB javaclasspath - MathWorks Deutschland. I am not aware that anything that shows classes.
However, you should consider that javaaddpath only adds libraries to the dynamic Java path (Add entries to dynamic Java class path - MATLAB javaaddpath - MathWorks Deutschland). For some Java features like events or for instance also database connections, the static path must be used (which is less convenient): Static Path of Java Class Path - MATLAB & Simulink - MathWorks Deutschland and Static Java classpath hacks - Undocumented Matlab
Thus. it may actually be that Matlab has the jar in the path but cannot execute anything with it, because it requires some callback features that are only available if everything was set up statically.
0 Comments
See Also
Categories
Find more on Call Java from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!