0

Documented way does not work:

>> javaaddpath('../../../build/classes/main/');
>> ls('../../../build/classes/main/')
.         ..        attempts  
>> ls('../../../build/classes/main/attempts')
.                    ..                   ImageViewer$1.class  ImageViewer.class    
>> import attempts.ImageViewer;
Error using import
Import argument 'attempts.ImageViewer' cannot be found or cannot be imported.
>> iv = attempts.ImageViewer
Undefined variable "attempts" or class "attempts.ImageViewer".

UPDATE

More obvious view of not working:

enter image description here

Since current directory is on the path, it should work. But it doesn't.

UPDATE 2

Versions:

javap -verbose ImageViewer.class | findstr "major"
  major version: 51

>> version -java
ans =
Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
  • Either the above duplicate or this one is acceptable: http://stackoverflow.com/questions/6983324/calling-java-from-matlab. Use either the above or this link to solve your problem. – rayryeng Feb 29 '16 at 21:55
  • As you see it just does not work without any error message. Don't see any explanations in "duplicates" – Suzan Cioc Feb 29 '16 at 21:59
  • I beg to differ. Try out the instructions of each of the highest rated answers in each duplicate **exactly** as laid out and it will work. I don't see fit to reopen this question. Good luck. – rayryeng Feb 29 '16 at 22:00
  • 3
    Also, you need to make sure that the Java version you are building your classes with **must be compatible** with the Java version that is shipped with MATLAB. If the Java class is compiled with a version **newer** than the one shipped with MATLAB, it will not work. See this comment for more insight: http://stackoverflow.com/questions/9520503/calling-java-from-matlab#comment32303941_9521010 – rayryeng Feb 29 '16 at 22:01
  • I don't need examples to work, I need my class to work. Sure you can leave question closed. Don't see any reason to solve this problem for those who does not have it – Suzan Cioc Feb 29 '16 at 22:01
  • @rayryeng if version would be newer, it would throw classdef exception, as it said in duplicates. – Suzan Cioc Feb 29 '16 at 22:02
  • 1
    What "classdef exception" would you expect? classdef is related to matlab classes, not to java classes. Please double check the version, I am sure you used the wrong java version to create the class files. You can display the java version using the `ver` command. – Daniel Feb 29 '16 at 22:21
  • You can't state that not matching JVM causes no any error message but just silently not works. – Suzan Cioc Feb 29 '16 at 22:31
  • Why do you refuse to simply check the version? – Daniel Feb 29 '16 at 22:42
  • I checked it as I can, it's 1.7, MATLAB's is newer – Suzan Cioc Feb 29 '16 at 22:49

0 Answers0