为什么在用javac编译java源文件的时候没问题,并且成功的生成了class文件,但是却无法用java命令运行?
图片是命令窗口的错误提示其内容是:MicrosoftWindows[版本6.1.7601]版权所有(c)2009MicrosoftCorporation。保留所有权利。C...
图片是命令窗口的错误提示
其内容是:
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>cd F:
F:\
C:\Users\Administrator>F:
F:\>java fx
Exception in thread "main" java.lang.NoClassDefFoundError: fx
Caused by: java.lang.ClassNotFoundException: fx
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: fx. Program will exit.
F:\>javac testFor1.java
F:\>java testFor1
Exception in thread "main" java.lang.NoClassDefFoundError: testFor1
Caused by: java.lang.ClassNotFoundException: testFor1
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: testFor1. Program will exit.
public class fx
{
public static void main(String args[])
{
int i;
int j;
int n=10;
System.out.println("菱形");
for (i=1;i<=n;i++)
{
for (j=i;j<n;j++)
{
System.out.print(" ");
}
for (j=i;j>=1;j--)
{
System.out.print("#");
}
for (j=2;j<=i;j++)
{
System.out.print("#");
}
System.out.println();
}
for (i=9;i>=1;i--)
{
System.out.print(" ");
for (j=i;j<9;j++)
{
System.out.print(" ");
}
for (j=i;j>=1;j--)
{
System.out.print("#");
}
for (j=2;j<=i;j++)
{
System.out.print("#");
}
System.out.println();
}
}
}
这是源代码,我在其他电脑上面运行过,代码没有问题 展开
其内容是:
Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
C:\Users\Administrator>cd F:
F:\
C:\Users\Administrator>F:
F:\>java fx
Exception in thread "main" java.lang.NoClassDefFoundError: fx
Caused by: java.lang.ClassNotFoundException: fx
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: fx. Program will exit.
F:\>javac testFor1.java
F:\>java testFor1
Exception in thread "main" java.lang.NoClassDefFoundError: testFor1
Caused by: java.lang.ClassNotFoundException: testFor1
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: testFor1. Program will exit.
public class fx
{
public static void main(String args[])
{
int i;
int j;
int n=10;
System.out.println("菱形");
for (i=1;i<=n;i++)
{
for (j=i;j<n;j++)
{
System.out.print(" ");
}
for (j=i;j>=1;j--)
{
System.out.print("#");
}
for (j=2;j<=i;j++)
{
System.out.print("#");
}
System.out.println();
}
for (i=9;i>=1;i--)
{
System.out.print(" ");
for (j=i;j<9;j++)
{
System.out.print(" ");
}
for (j=i;j>=1;j--)
{
System.out.print("#");
}
for (j=2;j<=i;j++)
{
System.out.print("#");
}
System.out.println();
}
}
}
这是源代码,我在其他电脑上面运行过,代码没有问题 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询