微科社区,轻松开发从此开始! 请登陆 免费注册

微科社区

当前位置:首页 > Java平台 > J2ME >

请高手指教!!!我是java新手!

时间:2017-01-23 03:31  浏览:努力统计中...
class Point { int x,y; /*Point(int a,int b) { x=a; y=b; }*/ Point() { } void output() { System.out.println(x); System.out.println(y); } public static void main(String[] args) { Point pt; //pt=new Point(3,3); pt=new Point(); //pt=new Point();
class Point
{
int x,y;
/*Point(int a,int b)
{
x=a;
y=b;
}*/
Point()
{
}
void output()
{
System.out.println(x);
System.out.println(y);
}
 
public static void main(String[] args)
{
Point pt;
//pt=new Point(3,3);
pt=new Point();
//pt=new Point();
//pt.x=10;
//pt.y=10;
pt.output();
}
执行出来结果应该是 
  0 0
但是javac后java Point.java结果却是:

E:\java>javac Point.java

E:\java>java Pointt.java.java
Exception in thread "main" java.lang.NoClassDefFoundError: Pointt/java/java
Caused by: java.lang.ClassNotFoundException: Pointt.java.java
  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: Pointt.java.java. Program will exit.


请高手指教。。。

E:\java>java Pointt.java.java
Exception in thread "main" java.lang.NoClassDefFoundError: Pointt/java/java


运行应该使用 java Point命令

这个是最基础的命令
编译:javac className.java
运行:java className [参数1] [参数2] [...]

E:\java>javac point.java

E:\java>java point.java
Exception in thread "main" java.lang.NoClassDefFoundError: point/java
Caused by: java.lang.ClassNotFoundException: point.java
  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: point.java. Program will exit.
这个是运行结果!上面那个复制错咯!!!

oh ,shit 首先执行过程出错,其次void output()最好写成public 然后x y初始化,

类应该是public

最后面少写一个}


Java code
public class Point{int x,y;/*Point(int a,int b){x=a;y=b;}*/Point(){}void output(){System.out.println(x);System.out.println(y);} public static void main(String[] args){Point pt;//pt=new Point(3,3);pt=new Point();//pt=new Point();//pt.x=10;//pt.y=10;pt.output();}}


还是不得行呀!最后那个 } 加起还是一样的!E:\java>javac Point.java

E:\java>java Point.java
Exception in thread "main" java.lang.NoClassDefFoundError: Point/java
Caused by: java.lang.ClassNotFoundException: Point.java
  at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
顶一下
(1)
100%
踩一下
(0)
0%
------分隔线------