[英]Setting Classpath and Sequentially invoking a jar
I am trying to write a bash script to automate the work of executing my files for the grader in my class. 我正在尝试编写bash脚本来自动执行为班级中的平地机执行文件的工作。
cd ReflectionJar
export CLASSPATH=.:$CLASSPATH:/MicahRamirez/out/artifacts/ReflectionJar/ReflectionJar.jar
java -jar ReflectionJar.jar Notepad ./MicahRamirez/ReflectionJar/otherclasses/Notepad
java -jar ReflectionJar.jar graff ./MicahRamirez/ReflectionJar/otherclasses/graff
java -jar ReflectionJar.jar quark ./MicahRamirez/ReflectionJar/otherclasses/quark
java -jar ReflectionJar.jar yparser ./MicahRamirez/ReflectionJar/otherclasses/yparser
java -jar ReflectionJar.jar reflectionPackage ./ReflectionJar/MicahRamirez/otherclasses/reflectionPackage
Directiory Structure: DirectoryStructure Pic 目录结构: DirectoryStructure Pic
I am currently receiving 我目前正在接收
./reflection.sh: line 4: export: `=': not a valid identifier
./reflection.sh: line 4: export: `./MicahRamirez/out/artifacts/ReflectionJar/ReflectionJar.jar': not a valid identifier
Error: Unable to access jarfile ReflectionJar.jar
...
My real roadblock are the first two errors. 我真正的障碍是前两个错误。 I have looked at quite a few SO posts to see how I would export the classpath and what I've found doesn't seem to work... 我看了很多SO帖子,看看如何导出类路径,发现的似乎不起作用...
I've tried 我试过了
export CLASSPATH=$CLASSPATH:./MicahRamirez/out/artifacts/ReflectionJar/ReflectionJar.jar
export CLASSPATH=./MicahRamirez/out/artifacts/ReflectionJar/ReflectionJar.jar
Neither have worked. 都没有工作。
When you specify the -jar
option, the classpath is taken from the Manifest file, and the environment variable and/or -cp
command-line arguments are ignored. 当您指定-jar
选项时,将从清单文件中获取类路径,并且将忽略环境变量和/或-cp
命令行参数。 See documentation : 参见文档 :
-jar -罐
Executes a program encapsulated in a JAR file. 执行封装在JAR文件中的程序。 The first argument is the name of a JAR file instead of a startup class name. 第一个参数是JAR文件的名称,而不是启动类的名称。 For this option to work, the manifest of the JAR file must contain a line in the form
Main-Class
: classname . 为了使此选项起作用,JAR文件的清单必须包含以下格式的行:Main-Class
: classname 。 Here, classname identifies the class with thepublic static void main(String[] args)
method that serves as your application's starting point. 在这里, 类名使用public static void main(String[] args)
方法标识该类,该方法用作应用程序的起点。When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored . 使用此选项时,JAR文件是所有用户类的源,而其他用户类路径设置将被忽略 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.