使用cmd时,我的简单程序出现以下错误:
“”“错误:发生了JNI错误,请检查您的安装,然后重试。线程“主”中的异常java.lang.UnsupportedClassVersionError:secondtohms已由Java Runtime的最新版本(类文件版本)编译。 55.0),此版本的Java运行时仅在java.lang.ClassLoader.defineClass1(本机方法)在java.lang.ClassLoader.defineClass(未知源)的java.security.SecureClassLoader.defineClass( java.net.URLClassLoader.defineClass的未知源)java.net.URLClassLoader.access $ 100的未知源(java.net.URLClassLoader $ 1.run的未知源)java.net.URLClassLoader $ 1.run的未知源(未知源)在java.security.AccessCon troller.doPrivileged(本机方法),位于java.net.URLClassLoader.findClass(未知源),位于java.lang.ClassLoader.loadClass(未知源),位于sun.misc.Launcher $ AppClassLoader.loadClass(未知源),位于java.lang。 sun.launcher.LauncherHelper.checkAndLoadMain(未知源)的ClassLoader.loadClass(未知源)“”“
程序在eclipse中运行得很好,但是当我在cmd中编译并运行它时,我得到了。对不起,我对此很陌生,非常感谢您的帮助。
我尝试重新安装Java SE Runtime Environment 8更新191。我还要指出的是,在尝试编译并通过cmd运行的每个小程序中,我都遇到相同的错误。
//****************************************************************
//The function of this application is to take user input in the form of an
//Integer (of seconds), and convert it/show it as Hours, Minutes and Seconds.
//********************************************************************
import java.util.Scanner;
public class SecondToHMS {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
int user_seconds, hours, hours_remainder, minutes, seconds;
final int HOURBASE = 3600;
final int MINSECBASE = 60;
System.out.print("Please input the number of seconds to be converted to Hours/Minutes/Seconds, and press Enter: ");
user_seconds = scan.nextInt(); //receives users input.
hours = user_seconds/HOURBASE; //users input divided by 3600 -- number of seconds in a hour.
hours_remainder = user_seconds%HOURBASE; //remainder captured, used for minutes and seconds.
minutes = hours_remainder/MINSECBASE; //remainder divided, used for minutes.
seconds = hours_remainder%MINSECBASE; // remainder's remainder calculated, used for seconds.
System.out.println(user_seconds + " seconds is equal to " + hours + " hours, " + minutes + " minutes and "
+ seconds + " seconds, or " + hours + ":" + minutes + ":" + seconds);
scan.close();
}
}