简体   繁体   English

使用“java”命令Centos运行.jar文件

[英]run .jar file with “java” command Centos

I'm trying to run a .jar file on my centos box, but it says "java: command not found". 我正在尝试在我的centos盒子上运行.jar文件,但它说“java:command not found”。

What's the best or easiest way to solve this? 什么是解决这个问题的最佳或最简单的方法? I was hoping for a yum command but not sure that that will exist for java? 我希望有一个yum命令,但不确定java是否存在?

Apparently some versions of CentOS doesn't come with a JVM installed due to some licensing restriction. 显然,由于某些许可限制,某些版本的CentOS没有安装JVM。 See HowTo Install Java on CentOS 4 and CentOS 5 for instructions. 有关说明,请参见如何在CentOS 4和CentOS 5上安装Java

You can use such command to check if Java is available in your repository: 您可以使用此命令检查存储库中是否有Java:

yum list | grep java

It should return something like that: 它应该返回类似的东西:

java-1.6.0-openjdk
java-1.6.0-sun

If such package exists you can install it using such command (run it as the root user): 如果存在此类包,则可以使用此命令安装它(以root用户身份运行):

yum install java-1.6.0-openjdk

Either the JRE is not installed or, more likely, its location is not included in your PATH environment variable. 未安装JRE,或者更有可能的是,其位置未包含在PATH环境变量中。 If the java executable is not in your PATH , you would need to use the full path & filename to execute it. 如果java可执行文件不在您的PATH ,则需要使用完整路径和文件名来执行它。

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

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