title: java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.FileChannelImpl
body: <p>I am working on an application that executes a <strong>Jython 2.5.3</strong> script from <strong>JAVA 1.6.027</strong>. The script just open a file using codecs library and it looks like this:</p>
  
  <pre><code>try:
      from codecs import open as codecs_open
  except ImportError:
      print 'ERROR', 'Could not import.'
  
  CODECS_LIST = ['latin-1', 'utf-8', 'utf-16', '1250', '1252']
  
  def open_file(filename, mode):
      '''
      DOC
      '''
      for encoding in CODECS_LIST:
          try:
              f = codecs_open(filename, mode, encoding)
              f.read()
              f.close()
              print 'INFO', "File %s supports encoding %s." % (filename.split("\\")[-1], encoding)
              ...
          except:
              ...
  </code></pre>
  
  <p>When I execute this script debugging in <strong>Eclipse</strong>, everything works OK, but when I execute the part of the JAVA application that invokes this script, I get this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class sun.nio.ch.FileChannelImpl
      at java.io.RandomAccessFile.getChannel(RandomAccessFile.java:253)
      at org.python.core.io.FileIO.fromRandomAccessFile(FileIO.java:173)
      at org.python.core.io.FileIO.&lt;init&gt;(FileIO.java:79)
      at org.python.core.io.FileIO.&lt;init&gt;(FileIO.java:57)
      at org.python.core.PyFile.&lt;init&gt;(PyFile.java:135)
      at org.python.core.PyTraceback.getLine(PyTraceback.java:65)
      at org.python.core.PyTraceback.tracebackInfo(PyTraceback.java:38)
      at org.python.core.PyTraceback.dumpStack(PyTraceback.java:109)
      at org.python.core.PyTraceback.dumpStack(PyTraceback.java:120)
      at org.python.core.Py.displayException(Py.java:1080)
      at org.python.core.PySystemState.excepthook(PySystemState.java:1242)
      at org.python.core.PySystemStateFunctions.__call__(PySystemState.java:1421)
      at org.python.core.Py.printException(Py.java:1053)
      at org.python.core.Py.printException(Py.java:1012)
      at org.python.util.jython.run(jython.java:264)
      at org.python.util.jython.main(jython.java:129)
  </code></pre>
  
  <p>The JAVA application is able to execute others similar jython scripts. I have detected that the <strong>class sun.nio.ch.FileChannelImpl</strong> is in the library rt.jar, which is inside <em>/bin/common/</em> folder and included in my <strong>classpath</strong> via <strong>jvm.cfg</strong> file:</p>
  
  <pre><code>...    
  #LIBRARY PATH
  ./bin/common;...
  ...
  </code></pre>
  
  <p>The same way I do it with other libraries that work fine.</p>
  
  <p>I have been stacked with this problem for a few days, so any help will be appreciated.
  Thank you</p>