Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. #include <string>
  2.  
  3. namespace LegacyLibrary {
  4. class LegacyClass {
  5. public:
  6. const std::string& getProperty() { return property; }
  7. void setProperty(const std::string& property) { this->property = property; }
  8. private:
  9. std::string property;
  10. };
  11. }
  12.  
  13. import com.googlecode.javacpp.*;
  14. import com.googlecode.javacpp.annotation.*;
  15.  
  16. @Platform(include="LegacyLibrary.h")
  17. @Namespace("LegacyLibrary")
  18. public class LegacyLibrary {
  19. public static class LegacyClass extends Pointer {
  20. static { Loader.load(); }
  21. public LegacyClass() { allocate(); }
  22. private native void allocate();
  23.  
  24. public native @ByRef String getProperty();
  25. public native void setProperty(String property);
  26. }
  27.  
  28. public static void main(String[] args) {
  29. LegacyClass l = new LegacyClass();
  30. l.setProperty("Hello World!");
  31. System.out.println(l.getProperty());
  32. }
  33.  
  34. Exception in thread "main" java.lang.NoClassDefFoundError: java.lang.ClassNotFoundException: com.test.LegacyLibrary
  35. at com.googlecode.javacpp.Loader.load(Loader.java:293)
  36. at com.googlecode.javacpp.Loader.load(Loader.java:271)
  37. at com.test.LegacyLibrary$LegacyClass.<clinit>(LegacyLibrary.java:12)
  38. at com.test.LegacyLibrary.main(LegacyLibrary.java:23)
  39. Caused by: java.lang.ClassNotFoundException: com.test.LegacyLibrary
  40. at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  41. at java.security.AccessController.doPrivileged(Native Method)
  42. at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  43. at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
  44. at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  45. at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  46. at java.lang.Class.forName0(Native Method)
  47. at java.lang.Class.forName(Class.java:169)
  48. at com.googlecode.javacpp.Loader.load(Loader.java:291)
  49. ... 3 more
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement