照着快速设置指南上面安装了JDK和JRE,便了一个最简单的JAVA程序放在桌面上,编译能通过,并且生成了CLASS文件,但是用命令执行CLASS文件大时候报如下错误:
tuliang@TL-desktop:~$ javac /home/tuliang/Desktop/Hello.java
tuliang@TL-desktop:~$ java /home/tuliang/Desktop/Hello.class
Exception in thread "main" java.lang.NoClassDefFoundError: /home/tuliang/Desktop/Hello/class
怎么会NoClassDefFound呢?我编的程序没有错啊!这么简单大程序也不可能出错啊!代码如下:
public class Hello
{
public static void main(String arg[])
{
System.out.println("hello");
}
}
我的环境变量配置如下:
tuliang@TL-desktop:~$ sudo update-alternatives --config java
There are 3 alternatives which provide `java'.
Selection Alternative
-----------------------------------------------
1 /usr/bin/gij-wrapper-4.1
+ 2 /usr/lib/jvm/java-gcj/jre/bin/java
* 3 /usr/lib/jvm/java-1.5.0-sun/jre/bin/java
Press enter to keep the default[*], or type selection number: 3
为什么就是不行呢~请高手帮忙指点一下。
请高手帮忙看一下,我的JAVA编译环境配置有什么问题
-
- 帖子: 10
- 注册时间: 2006-09-28 15:25
请高手帮忙看一下,我的JAVA编译环境配置有什么问题
上次由 tuliangde 在 2006-09-29 9:24,总共编辑 1 次。
-
- 帖子: 5
- 注册时间: 2005-12-15 23:30
-
- 帖子: 10
- 注册时间: 2006-09-28 15:25
- oneleaf
- 论坛管理员
- 帖子: 10441
- 注册时间: 2005-03-27 0:06
- 系统: Ubuntu 12.04
- GOVO
- 帖子: 427
- 注册时间: 2005-05-15 3:09
-
- 帖子: 26
- 注册时间: 2006-07-20 15:44
解释一下
root@zrt-desktop:/home/zrt/Desktop/TestDB/dist# java -jar TestDB.jar
java.io.FileNotFoundException: database.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at testdb.TestDB.getConnection(Main.java:48)
at testdb.TestDB.runTest(Main.java:31)
at testdb.TestDB.main(Main.java:17)
root@zrt-desktop:/home/zrt/Desktop/TestDB/dist# java -cp TestDB.jar
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
java.io.FileNotFoundException: database.properties (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at testdb.TestDB.getConnection(Main.java:48)
at testdb.TestDB.runTest(Main.java:31)
at testdb.TestDB.main(Main.java:17)
root@zrt-desktop:/home/zrt/Desktop/TestDB/dist# java -cp TestDB.jar
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
- patrickhe
- 帖子: 681
- 注册时间: 2005-07-21 19:13
- 来自: Peking, China
- 联系:
- kobe082002
- 帖子: 53
- 注册时间: 2005-12-01 1:21