我最近创建并编译了一个Java程序,但它不会从终端运行。它不是程序,因为它将从Eclipse运行。这是我尝试运行程序时从终端获得的内容:
Grants-MBP:~ Grant$ java /Users/Grant/Desktop/Pythagorean
Exception in thread "main" java.lang.NoClassDefFoundError: /Users/Grant/Desktop/Pythagorean
Caused by: java.lang.ClassNotFoundException: .Users.Grant.Desktop.Pythagorean
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
答案 0 :(得分:2)
导航到桌面文件夹
cd /Users/Grant/Desktop/
使用
调用javajava Pythagorean