java程序在命令提示符窗口下可以编译运行,但在Jcreator中可以编译但不能运行

来源:百度知道 编辑:UC知道 时间:2024/04/20 22:54:29
我安装了Jcreator4.0和JDK1.6,我是JAVA初学者,照着书上输入了一段程序,在命令提示符窗口下可以正确编译并运行,但是在Jcreator中可以编译不能运行,请帮我看看这是怎么回事啊?以下是程序:
import java.io.*;
public class plus
{
public static void main(String[] args)throws IOException
{
int num1,num2;
String str1,str2;
BufferedReader buf1,buf2;
buf1=new BufferedReader(new InputStreamReader(System.in));
System.out.println("the first number is :");
str1=buf1.readLine();
num1=Integer.parseInt(str1);
buf2=new BufferedReader(new InputStreamReader(System.in));
System.out.println("the second number is :");
str2=buf2.readLine();
num2=Integer.parseInt(str2);
System.out.println(num1+"+"+num2+"="+(num1+num2));

}
}
运行总是在输入第一个数后总是提示:
Exception in thread "main" java.lang.NumberFormatException: For input string: "the first number is :"
at java.lang.NumberFormatException.forInputS

我运行过了,这段程序没有什么大问题,就是你的类名Plus应该开头大写,而且必须和文件名一样,这点很重要,其次如果还有错误就是你编译环境没有弄好!如果你实在不知道怎么弄编译环境你可以下载JBUILDER,这个软件可以不用自己编译环境的,呵呵,希望对你有帮助!

建议你使用eclipse吧,我调试没问题