【发布时间】:2016-04-09 20:54:36
【问题描述】:
在这里尝试跟随:https://docs.oracle.com/javase/tutorial/getStarted/intro/index.html
我无法获得在 Java 中执行第 1 步的咒语。
我已尝试导出 CLASSPATH=。并导出 CLASSPATH= 但我什至还没有类文件。
有人能指出正确的方向吗?已经尝试了大部分基本帖子。
$uname -a
Linux box 3.19.0-41-generic #46-Ubuntu SMP Fri Dec 4 18:18:11 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ javac -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
$javac ./hello.java
Error: Could not find or load main class ..hello.java
$javac ./hello
Error: Could not find or load main class ..hello
$javac hello.java
Error: Could not find or load main class hello.java
$javac hello
Error: Could not find or load main class hello
$javac -cp . hello
Error: Could not find or load main class hello
$javac -d . hello
Unrecognized option: -d
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
$java -version
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
$ cat hello.java
public class hello
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
【问题讨论】:
-
编译:
$javac hello.java运行:$java hello -
您的
javac似乎调用了java。which javac的输出是什么? -
@wero - 你是对的! javac 已链接到 java。我的解决方案是: # rm /etc/alternatives/javac # ln -s /usr/local/java/jdk1.8.0_77/bin/javac /etc/alternatives/javac
标签: java