尝试运行简单的Java代码时出现UnsupportedClassVersion错误 [英] UnsupportedClassVersion error while trying to run simple Java code

查看:56
本文介绍了尝试运行简单的Java代码时出现UnsupportedClassVersion错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Windows 7上的命令提示符来编译程序.编译时遇到问题.我创建了一个测试程序:

I'm trying to compile my programs using the command prompt on Windows 7. I'm having a problem when I during compile. I created a test program:

class test
{
    public static void main (String args[])
    {
        System.out.println("this is working!!!!!!");
    }
}

我从命令行使用以下说明:

I use the following instructions from the command line:

cd \ 
cd summer
Javac test.java 
java test

我什至尝试使用javaw,但在弹出框中都得到了相同的消息

I have even tried using javaw and I get the same message but in a pop-up box

找不到主类,程序将退出.

Could not find the main class, program will exit.

有什么建议吗?

推荐答案

您正在使用不同版本的JDK.检查您的javac和java的版本.该错误告诉您Java和编译类不是同一版本.检查您的配置路径,在dos中键入"set"以查看详细信息.

You are using different versions of JDK. Check the versions on your javac vs java. This error is telling you that your java and compiled class are not same versions. Check your path for configuration, type "set" in dos to see details.

示例:如果您使用javac(版本7)编译了类,并使用java(版本6)执行了该类

Example: If you compiled your class with javac (version 7) and execute it with java (version 6)

这篇关于尝试运行简单的Java代码时出现UnsupportedClassVersion错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆