Classpath with network drive to run Java program
-
28-06-2021 - |
문제
I have a bunch of jars in a shared (Windows) network drive. I would like to refer those jars
using java -classpath /network/drive/path/* myClass
. I will be running this command from an applescript
so I have tried something like below-
do shell script "java -classpath smb://user:pass@server/shared/jars/* myClass"
but it doesn't seem to work, is there a way to do it rather than having a whole bunch of jar files in the local machine or inside the Application
package?
The above works on a Windows batch
script like
java -classpath S:\shared\jars\* myClass
해결책
Your Windows example is not really a fair comparison, as there you have clearly mapped a drive letter to the network path which you then use with your Java command. The equivalent on Mac OS is to mount a network volume, which you can do through Finder -> Go -> Connect to server, or via AppleScript using the mount volume
command. Either way, if you mount smb://user:pass@server/shared
you can then access its contents under the path /Volumes/shared
:
do shell script "java -classpath /Volumes/shared/jars/\\* myClass"