简体   繁体   English

在Java中指定运行时。

[英]Specifying the Runtime in java.

I am currently trying to run a Jar file. 我目前正在尝试运行一个Jar文件。 The problem is, the program is made in a way like: http://www.codingbat.com/ , so of course, it needs to compile the code as it goes, and use reflection to run it. 问题是,该程序是以如下方式制作的: http : //www.codingbat.com/ ,因此,当然,它需要在编译过程中编译代码,并使用反射来运行它。 The issue I am getting, is the fact that it does not specify that is must use JDK7 instead of the default. 我遇到的问题是事实,它没有指定必须使用JDK7而不是默认值。

Also, I am just wondering in the Runtime class, would the Runtime.getRuntime().loadLibrary(String libname) work if I set it to the folder directory of JDK7? 另外,我只是想在Runtime类中,如果将其设置为JDK7的文件夹目录,那么Runtime.getRuntime()。loadLibrary(String libname)是否可以工作?

Thank you for reading this. 谢谢您阅读此篇。

There is a way to do that in Java Web Start. Java Web Start中提供了一种方法。 For a JAR there is no specific to force a JVM to use. 对于JAR,没有强制使用JVM的特定方法。

One less graceful way would be to compile your classes with -target version javac parameter, so the byte code generated would be specific to target version you state. 一种不太合适的方法是使用-target version javac参数编译您的类,因此生成的字节码将特定于您声明的目标版本。 That would lead to an UnsupportedClassVersionError when the application is run using a JVM lower than what was mentioned in the "target" 当使用低于“目标”中提到的JVM的应用程序运行应用程序时,将导致UnsupportedClassVersionError

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM