当前位置: 技术问答>java相关
一个新手2天没有解决的java问题
来源: 互联网 发布时间:2015-09-20
本文导语: 我下载的软件是j2sdk-1_4_1-windows-i586.exe 安装后路径是c:j2sdk1.4.1 环境变量设置是 classpath为 .;c:j2sdk1.4.ilibdt.jar;c:j2sdk1.4.1libtools.jar path为c:winntsystem32;c:winnt;c:j2sdk1.4.1bin 编译后运行程序,系统提示错...
我下载的软件是j2sdk-1_4_1-windows-i586.exe
安装后路径是c:j2sdk1.4.1
环境变量设置是 classpath为 .;c:j2sdk1.4.ilibdt.jar;c:j2sdk1.4.1libtools.jar
path为c:winntsystem32;c:winnt;c:j2sdk1.4.1bin
编译后运行程序,系统提示错误为:
Exception in thread "main" java.lang.NoSuchMethodError: main
程序如下:
class Fruit
{
boolean seedless;
boolean seasonal;
float price;
void setProperties(boolean seed,boolean season,float cost)
{
seedless=seed;
seasonal=season;
price=cost;
}
void printProperties()
{
System.out.println("Following are properties of fruit");
if(seedless)
System.out.println("Fruit is seedless");
else
System.out.println("Fruit is seeded");
if(seasonal)
System.out.println("Fruit is seasonal");
else
System.out.println("Fruit is not seasonal");
System.out.println("Price is "+ price);
}
}
class FruitDemo
{
public static void main(String args[])
{
Fruit Orange=new Fruit();
Orange.setProperties(true,true,50.0F);
Orange.printProperties();
}
}
请指教错误出在那里,环境变量设置是否正确。谢谢!
安装后路径是c:j2sdk1.4.1
环境变量设置是 classpath为 .;c:j2sdk1.4.ilibdt.jar;c:j2sdk1.4.1libtools.jar
path为c:winntsystem32;c:winnt;c:j2sdk1.4.1bin
编译后运行程序,系统提示错误为:
Exception in thread "main" java.lang.NoSuchMethodError: main
程序如下:
class Fruit
{
boolean seedless;
boolean seasonal;
float price;
void setProperties(boolean seed,boolean season,float cost)
{
seedless=seed;
seasonal=season;
price=cost;
}
void printProperties()
{
System.out.println("Following are properties of fruit");
if(seedless)
System.out.println("Fruit is seedless");
else
System.out.println("Fruit is seeded");
if(seasonal)
System.out.println("Fruit is seasonal");
else
System.out.println("Fruit is not seasonal");
System.out.println("Price is "+ price);
}
}
class FruitDemo
{
public static void main(String args[])
{
Fruit Orange=new Fruit();
Orange.setProperties(true,true,50.0F);
Orange.printProperties();
}
}
请指教错误出在那里,环境变量设置是否正确。谢谢!
|
另外你应该用java FruitDemo 来运行。