質問

I try to build JAR with a Class-Path element in the MANIFEST.MF. I get the elements of the class path from an outside source (Maven in my case). Since the paths are absolute and beyond my control, they can contain weird characters like spaces.

Since spaces are used to separate items in the class path, this path doesn't work:

Class-Path: C:\User\Some Odd Name\project\target\project-1.0.0.jar

How can I escape / encode odd characters / whitespace in items of the classpath in the JAR Manifest?

役に立ちましたか?

解決

Elements in the Class-Path element are URLs, so the usual escaping rules apply (and you should use forward slashes as well):

Class-Path: /C:/User/Some%20Odd%20Name/project/target/project-1.0.0.jar

Note: The initial slash is necessary since C is not a valid network protocol (like http or ftp). If you were pedantic, it should be file:///C:/...

他のヒント

For me the caret character was the only way to successfully escape the withespace in a Windows classpath:

Class-Path: C:\User\Some^ Odd^ Name\project\target\project-1.0.0.jar
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top