Developers, Developers, Developers! Maksim Sorokin IT Blog

21May/102

java.lang.NoClassDefFoundError: Files

If you encounter the following kind of Exception, you probably configured %JAVA_HOME% variable incorrectly:

java.lang.NoClassDefFoundError: Files
Caused by: java.lang.ClassNotFoundException: Files
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
Could not find the main class: Files.  Program will exit.
Exception in thread "main"

For example, this could happen during GlassFish startup. The solution is to fix %JAVA_HOME% environment variable, so it would point to correct Java installation location.

Comments (2) Trackbacks (2)
  1. Thanks for the hint.

    For some reason -Djava.library.path is set to the Windows environment variable PATH, and that does not play nice with starting.

    If I change PATH to include only the java program files location it starts just fine.

    I have added the following to asenv.bat:
    REM for some reason java.library.path is set to PATH somewhere later
    REM playing havoc with booting glassfish
    set PATH=%AS_JAVA%\bin

    and now it works :)
    I will probably need to clean PATH in

  2. Leon, thanks for you comment.

    What about not “resetting” PATH variable, but just adding %AS_JAVA%\bin to it:

    set PATH=%PATH%;%AS_JAVA%\bin


Leave a comment