How to invoke groovy with 'java' from command line

后端 未结 5 1323
萌比男神i
萌比男神i 2020-12-29 09:41

I have to ship some groovy code to some users that have only java installed (no grooy, no $groovy_home, etc). I\'m trying to invoke groovy from the commandline but I\'m havi

5条回答
  •  梦毁少年i
    2020-12-29 10:25

    Watch out of [~]!

    java -cp .:~/path-to-groovy-all.jar YourClassName     # does not work
    java -cp ~/path-to-groovy-all.jar:. YourClassName     # works
    java -cp .:/full/path/to/goovy-all.jar YourClassName  # works
    

    In first line tilde is not processed by bash, and java can not understand it.

    In second line tilde is replaced by bash and everything works fine.

提交回复
热议问题