当前位置: 技术问答>linux和unix
linux下java图形界面程序有特殊要求吗?
来源: 互联网 发布时间:2015-04-20
本文导语: 标准控制台程序没问题可以正常运行 但是执行窗口出现就出错 //NotRunable.java import java.awt.*; public class NotRunable extends Frame { public static void main(String [] args) { Frame...
标准控制台程序没问题可以正常运行
但是执行窗口出现就出错
//NotRunable.java
import java.awt.*;
public class NotRunable extends Frame
{
public static void main(String [] args)
{
Frame f=new Frame();
f.setSize(1024,768);
f.show();
}
}
//End.
运行结果:
returned
end
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.jav
a.awt.peer.gtk.GtkToolkit
at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./
libgcj.so.3)
at 0x4025bc8e: java.lang.Error.Error(java.lang.String) (/usr/lib/./libgcj.s
o.3)
at 0x40329582: java.awt.AWTError.AWTError(java.lang.String) (/usr/lib/./lib
gcj.so.3)
at 0x40340c9d: java.awt.Toolkit.getDefaultToolkit() (/usr/lib/./libgcj.so.3
)
at 0x4034146e: java.awt.Window.getToolkit() (/usr/lib/./libgcj.so.3)
at 0x40336705: java.awt.Frame.addNotify() (/usr/lib/./libgcj.so.3)
at 0x403412d8: java.awt.Window.show() (/usr/lib/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr
/lib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMetho
dInvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/
usr/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40242dd8: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/./libgcj.s
o.3)
at 0x402ad02d: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte const, int, byte const, bo
olean) (/usr/lib/./libgcj.so.3)
at 0x08048910: ?? (??:0)
at 0x42015574: __libc_start_main (/lib/tls/libc.so.6)
at 0x080486c1: ?? (??:0)
另外原先我使用javax.swing.*可是在1.4.2for linux的J2SE中居然不能用
就算是import com.sun.java.swing.*;JFrame还是编译时提示错误
/etc/profile的最后我添加了一些classpath之类的配置
JAVA_HOME=/opt/j2sdk_nb/j2sdk1.4.2
JRE=/opt/j2sdk_nb/j2sdk1.4.2/jre
CLASSPATH=$JAVA_HOME/lib:$JRE/lib:.
PATH=$PATH:$JAVA_HOME/bin:$JRE/bin:.
export JAVA_HOME JRE CLASSPATH PATH
到底错在什么地方呢? 我觉得如果是设置问题的话编译 已经标准控制台出现也不应该成功
才对
但是执行窗口出现就出错
//NotRunable.java
import java.awt.*;
public class NotRunable extends Frame
{
public static void main(String [] args)
{
Frame f=new Frame();
f.setSize(1024,768);
f.show();
}
}
//End.
运行结果:
returned
end
Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.jav
a.awt.peer.gtk.GtkToolkit
at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./
libgcj.so.3)
at 0x4025bc8e: java.lang.Error.Error(java.lang.String) (/usr/lib/./libgcj.s
o.3)
at 0x40329582: java.awt.AWTError.AWTError(java.lang.String) (/usr/lib/./lib
gcj.so.3)
at 0x40340c9d: java.awt.Toolkit.getDefaultToolkit() (/usr/lib/./libgcj.so.3
)
at 0x4034146e: java.awt.Window.getToolkit() (/usr/lib/./libgcj.so.3)
at 0x40336705: java.awt.Frame.addNotify() (/usr/lib/./libgcj.so.3)
at 0x403412d8: java.awt.Window.show() (/usr/lib/./libgcj.so.3)
at 0x403831e7: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
at 0x403831a7: ffi_raw_call (/usr/lib/./libgcj.so.3)
at 0x402306e8: _Jv_InterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr
/lib/./libgcj.so.3)
at 0x40230ff4: _Jv_InterpMethod.run(ffi_cif, void, ffi_raw, _Jv_InterpMetho
dInvocation) (/usr/lib/./libgcj.so.3)
at 0x4022e504: _Jv_InterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/
usr/lib/./libgcj.so.3)
at 0x4038305c: ?? (??:0)
at 0x40242dd8: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/./libgcj.s
o.3)
at 0x402ad02d: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte const, int, byte const, bo
olean) (/usr/lib/./libgcj.so.3)
at 0x08048910: ?? (??:0)
at 0x42015574: __libc_start_main (/lib/tls/libc.so.6)
at 0x080486c1: ?? (??:0)
另外原先我使用javax.swing.*可是在1.4.2for linux的J2SE中居然不能用
就算是import com.sun.java.swing.*;JFrame还是编译时提示错误
/etc/profile的最后我添加了一些classpath之类的配置
JAVA_HOME=/opt/j2sdk_nb/j2sdk1.4.2
JRE=/opt/j2sdk_nb/j2sdk1.4.2/jre
CLASSPATH=$JAVA_HOME/lib:$JRE/lib:.
PATH=$PATH:$JAVA_HOME/bin:$JRE/bin:.
export JAVA_HOME JRE CLASSPATH PATH
到底错在什么地方呢? 我觉得如果是设置问题的话编译 已经标准控制台出现也不应该成功
才对
|
awt库不能加载
|
不知道你的JDK装好了吗?
我把你的程序运行了, 没有错误.只有如下的警告:
Warning: Cannot convert string "Escape,_Key_Cancel" to type VirtualBinding
Warning: Cannot convert string "Home,_Key_Begin" to type VirtualBinding
Warning: Cannot convert string "F1,_Key_Help" to type VirtualBinding
Warning: Cannot convert string "ShiftF10,_Key_Menu" to type VirtualBinding
Warning: Cannot convert string "F10,Shift_Key_Menu" to type VirtualBinding
Warning: Cannot convert string "KP_Enter,_Key_Execute" to type VirtualBinding
Warning: Cannot convert string "AltReturn,Alt_Key_KP_Enter" to type VirtualBinding
有一个FRAME出现
我把你的程序运行了, 没有错误.只有如下的警告:
Warning: Cannot convert string "Escape,_Key_Cancel" to type VirtualBinding
Warning: Cannot convert string "Home,_Key_Begin" to type VirtualBinding
Warning: Cannot convert string "F1,_Key_Help" to type VirtualBinding
Warning: Cannot convert string "ShiftF10,_Key_Menu" to type VirtualBinding
Warning: Cannot convert string "F10,Shift_Key_Menu" to type VirtualBinding
Warning: Cannot convert string "KP_Enter,_Key_Execute" to type VirtualBinding
Warning: Cannot convert string "AltReturn,Alt_Key_KP_Enter" to type VirtualBinding
有一个FRAME出现