我刚刚在Windows上安装了JGNAT( gnat-gpl-2010-jvm-bin.exe )
这是包含的手册中的示例代码 hello.adb :
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
Put_Line ("Hello GNAT for the JVM.");
end Hello;
首先,编译它: jvm-gnatmake hello.adb
jvm-gnatcompile -c hello.adb
jvm-gnatbind -x hello.ali
jvm-gnatlink hello.ali
看起来很好。所以让我们运行它: 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
知道为什么吗?
答案 0 :(得分:2)
这是修复。您必须将类路径设置为包含GNAT_libc.class的jar文件。
java -cp C:\GNATPRO\2010\lib\jgnat.jar;. hello