Topic: jcreator环境变量配置

  Print this page

1.jcreator环境变量配置 Copy to clipboard
Posted by: paladin1988
Posted on: 2007-10-09 14:21

我用Jcreator学习JAVA,对这个环境变量不熟悉;
我到baidu上看了好些关于classpath path配置的帖子,但是现在的人都是缺乏创新,这个抄袭那个,哪个抄袭这个的,看来看去也没有弄明白class,classpath说的什么问题;

我的JDK安装在E:\Java\jdk1.5.0_05,然后
path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;E:\Java\jdk1.5.0_05\bin;

java_home=E:\Java\jdk1.5.0_05;

classpath=.;E:\Java\jdk1.5.0_05\lib\dt.jar;E:\Java\jdk1.5.0_05\bin;E:\Java\jdk1.5.0_05\lib\tools.jar;G:\Myjava

我在G盘里建了一个名为Myjava 的文件夹用来存放写的JAVA文件;
在网络上看的,path环境变量作用是设置提供操作系统去寻找和执行应用程序的路径,也就是去JDK的BIN目录下加载JAVA的EXE程序;

而这个classpath呢?指定JVM要寻找的类名所在的 目录;也就是class文件的路径;比如我写的java程序放在Myjava文件夹下,编译后产生class文件,我就把classpath里添加G:\Myjava;我想问一下,我这样的做法对吗?

安装了jcreator之后,配置了如上的环境变量:写了一个程序,GuessNumber.java,放在Myjava的文件夹里,编译之后居然出现如下的情况:

/**
* @(#)GuessNumber.java
*
* GuessNumber.java application
*
* @author
* @version 1.00 2007/10/9
*/
import javax.swing.JOptionPane;
public class GuessNumber
{
public static void main(String args[])
{
System.out.println("给你一个1至100之间的整数,请猜测这个数");
int realNumber=(int)(Math.random()*100)+1;
int yourGuess=0,n=1;
String str=JOptionPane.showInputDialog("输入你的第1次猜测:");
yourGuess=Integer.parseInt(str);
while((n<3) && (realNumber!=yourGuess)) //循环条件
{
if(realNumber<yourGuess) //条件代码
{
str=JOptionPane.showInputDialog("猜大了,输入你第"+(++n)+"次的猜测:");
yourGuess=Integer.parseInt(str);
}
else if (realNumber>yourGuess) //条件代码
{
str=JOptionPane.showInputDialog("猜小了,输入你第"+(++n)+"次的猜测:");
yourGuess=Integer.parseInt(str);
}
}
if (n==3)
System.out.println("对不起,你的猜测失败");
else
System.out.println("猜对了!");
}
}

程序没有问题,编译通过了,但是运行的对话框里居然出现这样的情况:
--------------------Configuration: <Default>--------------------
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)

where options include:
-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

Process completed.
在Myjava里也产生了对应的class文件;
我又在DOS窗口里用java 命令进行编译,出现了
错误:无法读取GuessNumber.java

附件里的图片~~~

请问大家这是什么问题啊,还有给我讲下关于jcreator中classpath,path路径的设置问题,我上面的设置对吗?

我想这个问题应该是我们这些初学者jcreator经常常见的问题,希望大家解决哈~~
本人在 此先谢谢了~~

(缩略图,点击图片链接看原图)

2.Re:jcreator环境变量配置 [Re: paladin1988] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2007-10-09 18:43

很久没有用Jcreator了,我记的Jcreator会自动把当current working directory设置成classpath,所以你不用再设置classpath了。把你的classpath的环境变量去掉,应该可以解决你的问题。如果还有问题,请再回贴。

谢谢。

3.Re:jcreator环境变量配置 [Re: paladin1988] Copy to clipboard
Posted by: Cappuccino
Posted on: 2007-10-09 21:52

JCreator好像也不用怎么特别的配置的,基本上刚开始的时候按照提示把JDK目录设置好就可以了。而且自己用的多是JC3.5Pro,没怎么用过JC4……

4.Re:jcreator环境变量配置 [Re: HenryShanley] Copy to clipboard
Posted by: paladin1988
Posted on: 2007-10-12 17:11

HenryShanley wrote:
很久没有用Jcreator了,我记的Jcreator会自动把当current working directory设置成classpath,所以你不用再设置classpath了。把你的classpath的环境变量去掉,应该可以解决你的问题。如果还有问题,请再回贴。

谢谢。


我把classpath去掉了,可是还是出问题;

我是个初学者,本想用jcreator来学习的,可是现在连配置都成问题!!

5.Re:jcreator环境变量配置 [Re: paladin1988] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2007-10-13 06:03

It is very strange. What errors or exception you have when you run your Java program. Can you copy and paste the error after you removing the %classpath% system environment and exception here? If you run the Java program in JCreator, the the current working directory will be added into the classpath.

Thanks,
Jiafan

6.Re:jcreator环境变量配置 [Re: paladin1988] Copy to clipboard
Posted by: jancyu2008
Posted on: 2008-08-15 00:02

你新建文件时,要建立一个 JAVA FILES 不要建立APPLET FILES ,这个问题我以前遇见过,改过之后就OK勒,希望能帮助你

7.Re:jcreator环境变量配置 [Re: paladin1988] Copy to clipboard
Posted by: JiafanZhou
Posted on: 2008-08-15 23:03

There are some points I have overlooked about this topic.
1. java_home must be defined JAVA_HOME as all capital letters in your System Envrionment.
2. It is unnecessary and wrong to define classpath as the System Environment (S.E) unless your project relies this S.E. in the code
3. In JCreator, the classpath is defined as following by default:
"Configure -- > Option -- > JDK profiles --- > Edit"
This is where you want to include other jars into the project.
4. Never ever define classpath in S.E. it will cause some unexpected results.
5. jancyu2008's suggestion is noteworthy in terms of Applet is compiled and run in a different way from a standalone Java program.

Regards,
Jiafan

8.Re:jcreator环境变量配置 [Re: paladin1988] Copy to clipboard
Posted by: jancyu2008
Posted on: 2008-08-21 00:09

Yes, I was beginning to build a small Java program is not carefully established a small Applet procedures, the results there have been similar problems LZ


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923