类路径在 linux 下不起作用 [英] Classpath does not work under linux
问题描述
任何人都知道为什么这个命令在 Windows 中运行良好,但在 Linux 中我得到一个 ClassNotFoundException game.ui.Main
Anyone have an idea why this command works fine in Windows but in Linux I get a ClassNotFoundException game.ui.Main
java -cp ".;lib/*" game.ui.Main -Xms64m -Xmx128m
我的文件夹结构如下所示:lib/- 罐子游戏/- 类文件
my folder structure looks like this: lib/ - Jars game/ - Class files
这是最新的 Java 6.
This is the latest Java 6.
推荐答案
类路径语法依赖于操作系统.来自维基百科:
The classpath syntax is OS-dependent. From Wikipedia :
与文件密切相关系统,命令行类路径语法取决于操作系统.例如:
Being closely associated with the file system, the command-line Classpath syntax depends on the operating system. For example:
在所有类 Unix 操作系统上(例如 Linux 和 Mac OS X),目录结构具有 Unix 语法,用单独的文件路径分隔一个冒号(:").
on all Unix-like operating systems (such as Linux and Mac OS X), the directory structure has a Unix syntax, with separate file paths separated by a colon (":").
在 Windows 上,目录结构有一个 Windows 语法,每个文件路径必须用分号分隔(";").
on Windows, the directory structure has a Windows syntax, and each file path must be separated by a semicolon (";").
这不适用于 Classpath在清单文件中定义,其中每个文件路径必须由一个空格 (" "),无论操作系统.
This does not apply when the Classpath is defined in manifest files, where each file path must be separated by a space (" "), regardless of the operating system.
这篇关于类路径在 linux 下不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!