简体   繁体   English

如何在 Ubuntu 上的 .sh 文件中找到一个 java 类?

[英]How to locate a java class in a .sh file on Ubuntu?

I want to run a .sh file named ubiqstart.sh.我想运行一个名为 ubiqstart.sh 的 .sh 文件。 using java.使用java。 Specifically, I just want to execute a java class when running this .sh file.具体来说,我只想在运行这个 .sh 文件时执行一个 java 类。 But I keep getting this error: Error: Could not find or load main class com.ubiq.update.MainEntry.但我不断收到此错误: Error: Could not find or load main class com.ubiq.update.MainEntry. Seems like the system is not able to locate where the java class is at.似乎系统无法找到 java 类所在的位置。 However, when I directly type in and execute this command in terminal (under this exact directory), it runs perfectly.但是,当我在终端中(在这个确切的目录下)直接输入并执行此命令时,它运行得很好。

The script I use in the .sh file is: "../java/bin/java" -cp "./*" com.ubiq.update.MainEntry .我在 .sh 文件中使用的脚本是: "../java/bin/java" -cp "./*" com.ubiq.update.MainEntry

I wonder what causes this conflict and what should I do to make my .sh file to do the same thing as directly running the script.我想知道是什么导致了这种冲突,我应该怎么做才能使我的 .sh 文件与直接运行脚本做同样的事情。

When you are using older editors like vim or nano, just simply add a space after your classpath, like: com.ubiq.update.MainEntry .当您使用诸如 vim 或 nano 之类的旧编辑器时,只需在类路径后添加一个空格,例如: com.ubiq.update.MainEntry Especially if you convert the script from windows' .bat to Linux .sh特别是如果您将脚本从 Windows 的 .bat 转换为 Linux .sh

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

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