在 CLASSPATH 中有 Jar 的终端中编译 Java 代码
如何通过使用 CLASSPATH 中的 google-collections 在终端中使用 javac 编译代码?
尝试在终端中使用 javac 进行编译的代码示例(适用于 Eclipse)
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
public class Locate {
...
BiMap<MyFile, Integer> rankingToResult = HashBiMap.create();
...
}
< strong>在终端中编译
src 288 % javac Locate.java
Locate.java:14: package com.google.common.collect does not exist
import com.google.common.collect.BiMap;
^
Locate.java:15: package com.google.common.collect does not exist
import com.google.common.collect.HashBiMap;
^
Locate.java:153: cannot find symbol
symbol : class BiMap
location: class Locate
BiMap<MyFile, Integer> rankingToResult = HashBiMap.create();
^
Locate.java:153: cannot find symbol
symbol : variable HashBiMap
location: class Locate
BiMap<MyFile, Integer> rankingToResult = HashBiMap.create();
^
4 errors
我的 CLASSPATH
src 289 % echo $CLASSPATH
/u/1/bin/javaLibraries/google-collect-1.0.jar
How can you compile the code using javac in a terminal by using google-collections in CLASSPATH?
Example of code trying to compile using javac in a terminal (works in Eclipse)
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
public class Locate {
...
BiMap<MyFile, Integer> rankingToResult = HashBiMap.create();
...
}
Compiling in terminal
src 288 % javac Locate.java
Locate.java:14: package com.google.common.collect does not exist
import com.google.common.collect.BiMap;
^
Locate.java:15: package com.google.common.collect does not exist
import com.google.common.collect.HashBiMap;
^
Locate.java:153: cannot find symbol
symbol : class BiMap
location: class Locate
BiMap<MyFile, Integer> rankingToResult = HashBiMap.create();
^
Locate.java:153: cannot find symbol
symbol : variable HashBiMap
location: class Locate
BiMap<MyFile, Integer> rankingToResult = HashBiMap.create();
^
4 errors
My CLASSPATH
src 289 % echo $CLASSPATH
/u/1/bin/javaLibraries/google-collect-1.0.jar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
或者,Java 6 中的新功能,只需让它扫描目录
or, new in Java 6, just let it scan the directory