开发者

Trouble deciphering java class not visible from class loader error

开发者 https://www.devze.com 2022-12-10 20:48 出处:网络
I am trying to write some java code that will code the will get the Cocoa IKPictureTaker widget to load using Rococoa.I feel like I am getting closer now but I am getting an error and I am not quite s

I am trying to write some java code that will code the will get the Cocoa IKPictureTaker widget to load using Rococoa. I feel like I am getting closer now but I am getting an error and I am not quite sure why it is occurring. The error that I am getting is this:

Exception in thread "main" java.lang.ExceptionInInitializerError
at IKPictureTakerTest.main(IKPictureTakerTest.java:39)
Caused by: java.lang.IllegalArgumentException: interface IKPictureTaker$_Class is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581)
at org.rococoa.Rococoa.createProxy(Rococoa.java:164)
at org.rococoa.Rococoa.wrap(Rococoa.java:118)
at org.rococoa.Rococoa.createClass(Rococoa.java:50)
at IKPictureTaker.<clinit>(IKPictureTaker.java:31)

So there are two small classes that are interacting here first is the IKPictureTaker class:

public interface IKPictureTaker extends NSObject
{
   public static final _Class MYCLASS = Rococoa.createClass("IKPictureTaker", _Class.class);

   public interface _Class extends NSClass
   {
   /**
   * Returns a shared {@code IKPictureTaker} instance, creating it if necessary.
   * @return an {@code IKPictureTaker} object.
   */
   IKPictureTaker pictureTaker();
   }

   NSInteger runModal();
}

And the test class:

public class IKPictureTakerTest extends JFrame
{
   public static void main(String[] args) throws Exception
   {
      // You need a GUI before this will work.
      new IKPictureTakerTest().setVisible(true);

      NSAutoreleasePool pool = NSAutoreleasePool.new_();
开发者_StackOverflow社区
      QTKit instance = QTKit.instance;
      // Initialize the Quartz framework.
      Quartz.instance.toString();

      // Display the dialog.
     IKPictureTaker pictureTaker = IKPictureTaker.MYCLASS.pictureTaker();
     NSInteger result = pictureTaker.runModal();

     if (result.intValue() == 0) // NSCancelButton
     {
        System.out.println("User cancelled.");
     }
     else
     {
        assert result.intValue() == 1; // NSOKButton
        System.out.println("User chose an image.");
     }

     pool.release();
   }
}

This is the first time that I have done any command line compilation in java so I think that maybe by linker error is coming from that but I am not sure. Could anyone give me a hint as to what might be going on here?

P.S. It might be important to note that the Cocoa application does pop up with an empty window before this error occurs but there is not contents.


Not sure what your one line classes have (that is what libs are being loaded), but I think that's where your problem is. I got it to work by making sure Quartz is being loaded:

public interface IKPictureTaker extends NSObject {

    Library quartzINSTANCE = (Library) Native.loadLibrary("Quartz", Library.class);
    //...

}

public class IKPictureTakerTest extends JFrame {

   //...

   //QTKit instance = QTKit.instance;

   //Quartz.instance.toString();

   //...

}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号