I just installed JGNAT on Windows (gnat-gpl-2010-jvm-bin.exe)
This is a sample code hello.adb from the included manual:
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
Put_Line ("Hello GNAT for the JVM.");
end Hello;
First, compile it: jvm-gnatmake hello.adb
jvm-gnatcompile -c hello.adb
jvm-gnatbind -x hello.ali
jvm-gnatlink hello.ali
Looks fine. So let's run it: java hello
Exception in thread "main" java.lang.NoClassDefFoundError: jgnat/adalib/GNAT_libc
at hello.main(hello.adb)
Caused by: java.lang.ClassNotFoundException: jgnat.adalib.GNAT_libc
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Any idea why?
Here's the fix. You must set the classpath to the jar file containing GNAT_libc.class.
java -cp C:\GNATPRO\2010\lib\jgnat.jar;. hello
Related
I have a java program that uses dynamic reports fine in netbeans, and even works in exe and jar when I first run it. However, if I share the jar/exe (I've even sent it and re-downloaded it on my own computer), I get an error java.lang.classnotfoundexception: net.sf.jasperreports.engine.jrdatasource. However, I have double checked my jars and I do have this class. What could be the source of this problem then?
Thanks
Edit: full error:
Exception in thread "main" java.lang.NoClassDefFoundError:
net/sf/jasperreports/engine/JRDataSource
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
net.sf.jasperreports.engine.JRDataSource
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
if you get Caused by: java.lang.ClassNotFoundException: inside a jar file then, you need to provide the classpath arguments;
example:
java -cp my.jar -jar ExternalJarFileName.jar
you can also provide all jars use below command, only need to create a directory and put all external jars in to it and use path of directory in to below command:
java -cp my.jar;C:\externalJar\* mainpackage.MainClass
I have made many attempts to enter a command to run a JAR file correctly from the terminal, and I am 100% sure that all the JAR files and such are in the given paths, but I keep getting a ClassDefNotFoundException. Does it have anything to do with the way that I am entering the command?
C:\Users\ANNA\Downloads>"C:\Program Files\Java\jre1.8.0_45\bin\java.exe"
-Djava.library.path="C:\Users\ANNA\Downloads\Windows64_Libjitsi\lib\native\windows-64"
-cp
"C:\Users\ANNA\Downloads\SimplifiedConnectionProvider.jar;C:\Users\ANNA\Downloads\Windows64_Libjitsi"
Core.PublicService
Exception in thread "main" java.lang.NoClassDefFoundError: org/jitsi/service/lib
jitsi/LibJitsi
at Core.PublicService.<clinit>(PublicService.java:38)
Caused by: java.lang.ClassNotFoundException: org.jitsi.service.libjitsi.LibJitsi
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Didn't work. Tried again:
C:\Users\ANNA\Downloads>"C:\Program Files\Java\jre1.8.0_45\bin\java.exe" -Djava.
library.path="C:\Users\ANNA\Downloads\Windows64_Libjitsi\lib\native\windows-64"
-cp C:\Users\ANNA\Downloads\SimplifiedConnectionProvider.jar;C:\Users\ANNA\Downl
oads\Windows64_Libjitsi Core.PublicService
Exception in thread "main" java.lang.NoClassDefFoundError: org/jitsi/service/lib
jitsi/LibJitsi
at Core.PublicService.<clinit>(PublicService.java:38)
Caused by: java.lang.ClassNotFoundException: org.jitsi.service.libjitsi.LibJitsi
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Didn't work. Tried again:
C:\Users\ANNA\Downloads>"C:\Program Files\Java\jre1.8.0_45\bin\java.exe" -Djava.
library.path=C:\Users\ANNA\Downloads\Windows64_Libjitsi\lib\native\windows-64 -c
p C:\Users\ANNA\Downloads\SimplifiedConnectionProvider.jar;C:\Users\ANNA\Downloa
ds\Windows64_Libjitsi Core.PublicService
Exception in thread "main" java.lang.NoClassDefFoundError: org/jitsi/service/lib
jitsi/LibJitsi
at Core.PublicService.<clinit>(PublicService.java:38)
Caused by: java.lang.ClassNotFoundException: org.jitsi.service.libjitsi.LibJitsi
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
Note that the class "org.jitsi.service.libjitsi.LibJitsi" really is in a JAR file whose real location is in the folder "C:\Users\Anna\Downloads\Windows64_Libjitsi", which is the class path for JAR files that I am attempting to specify on the command line.
You have add the JAR to the CLASSPATH, not the folder which contains this JAR. So the -cp argument should something be like this C:\Users\ANNA\Downloads\SimplifiedConnectionProvider.jar;C:\Users\ANNA\Downloads\Windows64_Libjitsi\the_name_of_the_JAR.jar.
While adding custom jar files in the project and executing some java code I am getting this error any idea how to solve this .There is no error in code ,it was running smoothly before this happen.
Exception in thread "main" java.lang.NoClassDefFoundError: org/aspectj/lang/Signature
at com.util.DfExSession.connectToDocbase(DfExSession.java:18)## Heading ##
at com.console.TestConsole.main(TestConsole.java:17)
Caused by: java.lang.ClassNotFoundException: org.aspectj.lang.Signature
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
Look's like the aspectjrt.jar is missing in your classptah. Download & add it to your classpath.
I want to execute a Java class from a bat file and it include usage of opencsv.jar.
Below is the code:
#echo off
set path=%PATH%;C:\Program Files (x86)\Java\jdk1.6.0\bin
javac -cp opencsv.jar ArbitrageUsingThread.java
java ArbitrageUsingThread
I am getting the following error when running it. I think there is some problem with including opencsv.jar Can anyone help me with this?
Error
Exception in thread "main" java.lang.NoClassDefFoundError: au/com/bytecode/openc
sv/CSVWriter
at ArbitrageUsingThread.main(ArbitrageUsingThread.java:67)
Caused by: java.lang.ClassNotFoundException: au.com.bytecode.opencsv.CSVWriter
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
java is similar to javac for classpath.
Under linux:
java -cp opencsv.jar:. ArbitrageUsingThread
Under windows:
java -cp opencsv.jar;. ArbitrageUsingThread
I have a batch file which runs on XP:
#echo off
#setlocal
set CWD=%~dp0
set JYTHON_HOME=%CWD%
set LIB_DIR=%JYTHON_HOME%/lib
java -cp %LIB_DIR% -jar %LIB_DIR%/jython.jar -Djython.home=%CWD%
-Dpython.path=%LIB_DIR%;%CWD%/ext %LIB_DIR%clenotes/clenotes.py %*
#endlocal
I want to run this file on Windows 7.
EDIT:
When I run it this error occurs:
Exception in thread "main" java.lang.NoClassDefFoundError:
folder\CLENotes\lib Caused by: java.lang.ClassNotFoundException:
folder\CLENotes\lib
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Actually it is very simple, I needed to change the fowardslashes (/) to backslashes.