简体   繁体   English

在linux中设置类路径并运行jar文件以生成可执行文件

[英]set class path in linux and run the jar file making executable

I am trying to run the jar file on linux created from windows using jdk7 . 我试图在使用jdk7从Windows创建的Linux上运行jar文件。 I am using the following command to run the 我正在使用以下命令运行

  java -jar jarfile.jar

its running the jar and throwing the exception as un recognised class format version. 它运行jar并将异常作为未识别的类格式版本抛出。 because linux is showing the java version as 1.4.2 while i have extracted the jdk1.7 in the root directory but it is still taking the java version as 1.4.2 . 因为linux将Java版本显示为1.4.2而我已在根目录中提取了jdk1.7,但它仍将Java版本命名为1.4.2。 what i have to do to run the jar file created using jdk1.7 . 我必须做些什么来运行使用jdk1.7创建的jar文件。 I have extracted the java (jdk1.7) on linux in root directory. 我已经在Linux的根目录中提取了Java(jdk1.7)。

You need to specify the JDK 1.7 on your path eg 您需要在路径上指定JDK 1.7,例如

$ PATH=/jdk17/bin:$PATH

Note how you specify not just the path to the 1.7 installation, but the bin path within that. 请注意,您如何指定不只是路径1.7安装,但bin路径within说。

Typing 打字

$ which java

after you've changed the PATH will confirm if this has worked. 更改后, PATH将确认是否有效。

Make sure jdk1.7 in front of jdk1.4.2 in system variable PATH. 确保系统变量PATH中jdk1.4.2前面的jdk1.7。 Do you have installed oracle in your Linux OS? 您是否在Linux操作系统中安装了oracle? I have encountered the same question in windows OS because I have installed oracle. 我在Windows操作系统中遇到了相同的问题,因为我已经安装了oracle。 If some software just like oracle is installed, maybe it will insert jdk1.4 in front of all other software paths in system variable PATH. 如果安装了某些软件(例如oracle),则可能会将jdk1.4插入系统变量PATH中所有其他软件路径的前面。

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

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