开发者

Compiling Java code in terminal having a Jar in CLASSPATH

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 HashBi开发者_运维百科Map
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


  javac -cp /u/1/bin/javaLibraries/google-collect-1.0.jar Locate.java

or, new in Java 6, just let it scan the directory

  javac -cp '/u/1/bin/javaLibraries/*' Locate.java
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜