• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in java path in configuring jnotify and libnotify.so

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have developed an application using some of swing components that application is using jnotify to monitor folder, it is working fine in eclipse but when I produce jar file and try to execute that jar on my system it show me below error, I tried a lot in solving this error
but it is still giving me the same error, Please tell what I am doing wrong.

$$ java -jar DemoJFileChooser.jar
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: net/contentobjects/jnotify/JNotifyListener
at DemoJFileChooser.actionPerformed(DemoJFileChooser.java:124)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3311)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassNotFoundException: net.contentobjects.jnotify.JNotifyListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 37 more

Contents of my jar is
DemoJFileChooser.jar
|
|--Globals.class
|
|--FolderHandler$Listener.class
|
|--FolderHandler.class
|
|--DemoJFileChooser$2.class
|
|--DemoJFileChooser$1.class
|
|--DemoJFileChooser.class
|
|--CmdExe.class
|
|--.project
|
|--.classpath
|
|--META-INF
| |
| |--MANIFEST.MF
|
|--lib
| |
| |--swt.jar
| |
| |--libjnotify.so
| |
| |--jnotify-0.94.jar


.classspath file content is

<classpath><classpathentry kind="src" path="src"/><classpathentry combineaccessrules="false" exported="true" kind="src" path="/org.eclipse.swt"/><classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.osgi_3.7.2.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.osgi.source_3.7.2.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.core.commands_3.6.0.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.core.commands.source_3.6.0.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.equinox.common_3.6.0.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.equinox.common.source_3.6.0.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.equinox.registry_3.5.101.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.equinox.registry.source_3.5.101.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.core.runtime_3.7.0.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.core.runtime.source_3.7.0.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.text_3.5.101.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.text.source_3.5.101.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.jface_3.7.0.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.jface.source_3.7.0.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.jface.text_3.7.2.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.jface.text.source_3.7.2.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.ui.workbench_3.7.1.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.ui.workbench.source_3.7.1.dist.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/com.ibm.icu_4.4.2.v20110823.jar" sourcepath="/usr/lib/eclipse/plugins/com.ibm.icu_4.4.2.v20110823.jar"/><classpathentry kind="lib" path="/usr/lib/eclipse/plugins/org.eclipse.ui.forms_3.5.101.dist.jar" sourcepath="/usr/lib/eclipse/dropins/sdk/plugins/org.eclipse.ui.forms.source_3.5.101.dist.jar"/><classpathentry kind="lib" path="lib/jnotify-0.94.jar" sourcepath="lib/jnotify-0.94.jar"><attributes><attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="IrodsTest/lib"/></attributes></classpathentry><classpathentry kind="lib" path="lib/swt.jar"/><classpathentry kind="output" path="bin"/></classpath>


.project file content is

<projectDescription><name>IrodsTest</name><comment/><projects>
</projects><buildSpec><buildCommand><name>org.eclipse.jdt.core.javabuilder</name><arguments>
</arguments></buildCommand></buildSpec><natures><nature>org.eclipse.jdt.core.javanature</nature></natures></projectDescription

Thanks in advance!
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which class is it that it can't find? Where is that .class file? How are you adding it to your classpath?
 
humanshu bhatia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is showing below error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: net/contentobjects/jnotify/JNotifyListener

so I think it is not able to detect JNotifyListener.class but as I mention in directory structure it is present in lib/jnotify-0.94.jar this contain /net/contentobjects/jnotify/JNotifyListener.class so I dont know why it is not detecting this.
/lib/ folder in above mentioned directory structure also contain libjnotify.so so I think there is some issue in detecting libjnotify.so or jnotify-0.94.jar but I dont know what it is.
And I run this command also
java -Djava.library.path=/home/humanshu/jnotify/jnotify-0.94.jar -jar DemoJFileChooser.jar

in which jnotify folder contains both libjnotify.so or jnotify-0.94.jar but still it is giving same error.

I also uses System.getProperty("java.library.path"); to print path but it is not showing anything and also I set path using
$$ echo $LD_LIBRARY_PATH
/opt/openmpi/lib:/usr/local/bin:/usr/lib/jvm/java-7-openjdk-amd64/lib

$$ ls -l /usr/lib/jvm/java-7-openjdk-amd64/lib
total 19176
drwxr-xr-x 3 root root 4096 May 1 09:43 amd64
-rw-r--r-- 1 root root 8984185 Apr 25 15:43 ct.sym
-rw-r--r-- 1 root root 151520 Apr 25 15:43 dt.jar
-rw-r--r-- 1 root root 19429 Apr 25 15:43 ir.idl
-rw-r--r-- 1 root root 447081 Apr 25 15:42 jconsole.jar
lrwxrwxrwx 1 root root 16 Apr 25 20:31 jexec -> ../jre/lib/jexec
-rw-r--r-- 1 root root 38692 Aug 22 19:22 jnotify-0.94.jar
-rw-r--r-- 1 root root 1637 Apr 25 15:43 orb.idl
-rw-r--r-- 1 root root 2605088 Apr 25 15:42 sa-jdi.jar
-rw-r--r-- 1 root root 7365572 Apr 25 15:42 tools.jar


As we can see above lib folder contains jnotify-0.94.jar, I still dont know why it is giving this error.


 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have concrete solution, but you can try following steps and see if they help.

1) export LD_LIBRARY_PATH, I have seen this issue before, echo will display the path but for some reason its not picked by jvm unless its exported.
2) Open the class in Eclipse and check if the breadcrumb is pointing to same jar file.
3) I think .classpath and .project files are not required in your jar file, try removing them (or at least remove .classpath)

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see you have put some JAR files and also the native library (libjnotify.so) inside the lib folder of your own JAR file.

That does unfortunately not work. Java will not look in the lib folder of your JAR file and load nested JARs. Putting JAR files (or native libraries) inside JAR files is not supported. (It works with WAR files for webapplications, but not with regular JAR files).

You will have to take the nested JARs and the native library outside of your own JAR file and set the classpath and the path for loading the native library appropriately.

To specify to Java where to look for native libraries, you can use the "-Djava.library.path=..." option: java -Djava.library.path=C:\MyProject\lib com.mycompany.MyProgram
 
humanshu bhatia
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Fat Jar Eclipse Plug-In http://fjep.sourceforge.net/ and its tutorial http://fjep.sourceforge.net/fjeptutorial.html and then I use export option of eclipse and selecting Runnable JAR file and now it is working fine except that size of jar is now 15 times of previous jar file.
 
Praful Thakare
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


That does unfortunately not work. Java will not look in the lib folder of your JAR file and load nested JARs. Putting JAR files (or native libraries) inside JAR files is not supported. (It works with WAR files for webapplications, but not with regular JAR files).



I would be bit reluctant to agree

Runnable jar files (including dependencies jars) can be created, either manually or using maven plugins,

for manual example look here
.


humanshu , what are contents of your MANIFEST file ?
 
Praful Thakare
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I use Fat Jar Eclipse Plug-In



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic