在Mac OS中将JAR添加到CLASSPATH [英] Adding JAR to CLASSPATH in Mac OS
本文介绍了在Mac OS中将JAR添加到CLASSPATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Mac OS下设置CLASSPATH for Java。
I am trying to set up the CLASSPATH for Java under Mac OS.
具体来说,我正在尝试添加几个JAR档案。
Specifically I am trying to add a couple of JAR archives to it.
如果我这样做:
## Setting up ASM bytecode instructor library
export CLASSPATH=$CLASSPATH:/Users/fork/Dev/ASM/lib/all/asm-all-3.3.1.jar
一切正常。但是,如果我像文档推荐的那样设置它:
It works fine. However, if I set it like the documentation recommends:
## Setting up ASM bytecode instructor library
export CLASSPATH=$CLASSPATH:/Users/fork/Dev/ASM/lib/all/*
似乎不合适工作。
我要添加的东西,比如10个罐子,一个一个地添加听起来不切实际。
The thing is that I want to add, let's say 10 jars, it sounds impractical to add one-by-one.
是否有解决方案?
推荐答案
您必须分别在类路径上设置jar。
虽然有很多方法可以解决这个问题。我使用的是使用包含以下内容的shell脚本启动Java应用程序:
You must set the jars on the classpath individually. There are ways around this though. One that I use is starting the java app with a shell script that contains something like this:
cd $JAR_DIR
jars=($(ls *.jar))
JAR_PATH=""
dir=$(pwd)
for i in "${jars[@]}"; do
JAR_PATH="${JAR_PATH}:$dir/$i"
done
CLASSPATH=$CLASSPATH:$JAR_PATH
这将有效。
这篇关于在Mac OS中将JAR添加到CLASSPATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文