title: How to instantiate Java class from MATLAB?
body: <p>Documented way does not work:</p>
  
  <pre><code>&gt;&gt; javaaddpath('../../../build/classes/main/');
  &gt;&gt; ls('../../../build/classes/main/')
  .         ..        attempts  
  &gt;&gt; ls('../../../build/classes/main/attempts')
  .                    ..                   ImageViewer$1.class  ImageViewer.class    
  &gt;&gt; import attempts.ImageViewer;
  Error using import
  Import argument 'attempts.ImageViewer' cannot be found or cannot be imported.
  &gt;&gt; iv = attempts.ImageViewer
  Undefined variable "attempts" or class "attempts.ImageViewer".
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>More obvious view of not working:</p>
  
  <p><a href="https://i.stack.imgur.com/gtLcA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gtLcA.jpg" alt="enter image description here"></a></p>
  
  <p>Since current directory is on the path, it should work. But it doesn't.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>Versions:</p>
  
  <pre><code>javap -verbose ImageViewer.class | findstr "major"
    major version: 51
  
  &gt;&gt; version -java
  ans =
  Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  </code></pre>