无法访问cygwin下的jarfile [英] Unable to access jarfile under cygwin

查看:537
本文介绍了无法访问cygwin下的jarfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在这里有许多无法访问jarfile的问题,但我觉得这是不同的,足以保证自己的线程。

I know there are many "unable to access jarfile" questions on here, but I do feel this is different enough to warrant its own thread.

我写作这个演练的一部分涉及安装Cygwin和运行.jar文件。

I am writing a walkthrough, part of this walkthrough involves installing Cygwin and running a .jar file.

问题是这个.jar文件需要从多个目录调用,比我的读者必须在每次需要运行它时输入.jar的完整路径,我希望他们只有在对Cygwin进行简单配置后才必须输入.jar文件命令。

The problem is that this .jar file needs to be called from multiple directories, and rather than have my readers have to enter the full path to the .jar every time they need to run it, I would like them only to have to enter the .jar file command after having made a simple configuration to Cygwin.

我已经尝试将PATH添加到〜/ .bashrc并尝试添加CLASSPATH,但是没有成功。

I have tried adding the PATH to ~/.bashrc and have also tried adding the CLASSPATH, but have had no success.

每次调用 java -jar file.jar 我得到错误:无法访问jarfile file.jar

我应该如何解决这个问题?

What should I do to resolve this?

我已经和我的婆婆说过话,谁知道一点关于Linux,他建议我创建一个包装器来执行jar,我已经快速搜索,但找不到任何简单。

I have spoken to my bro-in-law, who knows a bit about Linux, and he has suggested that I create a wrapper to execute the jar, I have had a quick search, but can't find anything simple.

任何建议?

推荐答案

Cygwin已经提供了一种转换在UNIX(POSIX)样式路径和Windows(MS-DOS)样式路径之间,它被称为 cygpath

Cygwin already provides a way to convert between UNIX (POSIX)-style paths and Windows (MS-DOS)-style paths, it's called "cygpath".

尝试:

java -jar `cygpath -w ./foo/bar/file.jar command file.1 file.2`

注意:这些是围绕cygpath调用的反引号。

Note: Those are backticks surrounding the cygpath invocation.

使用cygpath不需要编写自己的bash脚本来传递东西,并且可以找到jar文件您的计算机上的任何位置。

Using cygpath eliminates the need to write your own bash script to pass things to, and the jar file can be located anywhere on your computer.

这篇关于无法访问cygwin下的jarfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆