简体   繁体   English

运行Java时,如何解决输入JAR文件完整路径的需要?

[英]When running java how do I get around the need to enter the full path of my JAR file?

On linux, using bash command line, I am running java to produce some plantuml diagrams. 在Linux上,使用bash命令行,我正在运行Java以生成一些plantuml图。 If I run the following: 如果我运行以下命令:

java -jar plantuml.jar Radio_1.2Rad_1200K.uml

I get the error: 我得到错误:

ERROR: Unable to access jarfile plantuml.jar

I did a "locate plantuml.jar" and found it, so then I used the full path of the JAR file and the command works: 我做了一个“找到plantuml.jar”并找到了它,因此我使用了JAR文件的完整路径,并且该命令起作用了:

java -jar /usr/lib/eclipse/configuration/org.eclipse.osgi/384/0/.cp/lib/plantUml/plantuml.jar Radio_1.2Rad_1200K.uml

Is there some java path I need to setup in order for java to locate the JAR file? 我是否需要设置一些Java路径才能使Java找到JAR文件? or must I always use the full path? 还是必须始终使用完整路径? or do I need to move the JAR file to some special location? 还是需要将JAR文件移动到某个特殊位置?

"java -jar" looks for the named JAR file by its relative or absolute filename as given. “ java -jar”通过给定的相对或绝对文件名查找命名的JAR文件。

It seems you are using plantUml from an Eclipse-based installation. 看来您正在使用基于Eclipse的安装中的plantUml。 If you need to do that repeatedly, you could create a copy of the JAR file that you need, or create a shell script for you to use. 如果需要重复执行此操作,则可以创建所需的JAR文件的副本,或创建供您使用的Shell脚本。

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

相关问题 Java:运行 JAR 文件时如何获取文件的路径 - Java: How to get path of a file when running JAR file 如何获取正在运行的jar文件所在目录的路径? - How to get the path of a directory where my running jar file is? Java:以JAR格式运行时的文件路径 - Java: file path when running from as JAR 如何在UNIX上找到正在运行的jar文件路径? - How I find my running jar file path on unix? 运行应用程序时,如何传递Java命令执行的附加jar? - How do I pass an additional jar do my java command when running application? 用Java创建jar文件时如何获取文件路径 - How to get the path of file when make a jar file in Java 如何将jar添加到Java编译路径? - How do I add my jar to Java compilation path? 从批处理文件运行Java时,如何获取Java项目中文件的路径? - How to get the path of a file in my java project when running java from batch file? 如何在 class 路径的当前目录中获取 JAR 文件以执行 Java? - How do I get a JAR file in the current directory in the class path for a Java execution? 如果将jar文件下载到项目中并将其包含在“构建路径”中,该如何将杰克逊类导入Java文件中? - How do I import jackson classes into a Java file if I've downloaded the jar file into my project and included it into my Build Path?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM