javac compiling error ( mising package)
javac 編譯java源文件時(shí),提示 package does not exist 的錯(cuò)誤
Test.java
import java.security.MessageDigest; import org.apache.commons.codec.binary.Hex;public class Test{public static void main(String args[]){boolean isAlarmed = true;boolean aa = isAlarmed || false;String queryTimestamp = "1970-01-01T00:00:00+0000";System.out.println(queryTimestamp.getBytes());try{MessageDigest md5 = MessageDigest.getInstance("MD5");System.out.println(md5.digest("stringtodigest".getBytes()));byte[] value = "stringtodigest".getBytes();md5.update(value);byte[] digest = md5.digest();System.out.println(new String(Hex.encodeHex(digest)));System.out.println(md5.digest("stringtodigest".getBytes())); System.out.println(md5.digest("stringtodigest".getBytes()));}catch(Exception e){ } } }javac Test.java編譯的時(shí)候報(bào)錯(cuò)!
解決辦法:
1. 到mvn repository(http://mvnrepository.com/artifact/commons-codec/commons-codec/1.7)上面吧缺少的 jar 包下載下來,
2. 然后給 CLASSPATH 環(huán)境變量在添加一下這個(gè)jar 包所在的路徑,就可以了。
---------------------------------------------------------------------------------------
參考:https://www.linuxquestions.org/questions/programming-9/javac-compiling-error-mising-package-669775/
javac compiling error ( mising package)
First i have to say I am very new to java. I downloaded java codes from the Internet and try to compile them using javac. I got following error,
Code:
C:\temp\javacrypt>"C:\Program Files\Java\jdk1.6.0_06\bin\javac" RSAExample.java .\BaseCrypto.java:1: package org.apache.commons.codec does not exist import org.apache.commons.codec.DecoderException;^ .\BaseCrypto.java:2: package org.apache.commons.codec.binary does not exist import org.apache.commons.codec.binary.Hex;^ .\BaseCrypto.java:26: cannot find symbol symbol : class DecoderException location: class BaseCryptopublic static byte[] asByte(String hexString) throws DecoderException {^ .\BaseCrypto.java:16: cannot find symbol symbol : variable Hex location: class BaseCryptoreturn new String(Hex.encodeHex(buf));^ .\BaseCrypto.java:27: cannot find symbol symbol : variable Hex location: class BaseCryptoreturn Hex.decodeHex(hexString.toCharArray());^ 5 errors
I guess i just missed some packages like "org.apache.commons.codec.*",
and that package is not part of standard jdk, right?
How do i get those package? I also have netbean and eclipse, but I haven't tried to use them yet.
-----------------
When you get the package, which is probably a .jar file, add that .jar file to your classpath (environment variable).
EDIT:?Specifically, here.
EDIT: I believe on Windows it's something like...
SET CLASSPATH=%CLASSPATH%;C:\path\to\jar\jarfile.jar
----------------------
I downloaded the jar file suggested by elprawn, and it work great!! thank you so much.
I am curious about the suggestion from jay73. Is the package management the software like "yum" or "apt-get", right? What keyword should use to search for it?
----------------------
On a system that uses apt, you can use?
aptitude search commons
and you'should get a list of the available commons?libraries.On?ubuntu:
?
轉(zhuǎn)載于:https://www.cnblogs.com/oxspirt/p/7443485.html
總結(jié)
以上是生活随笔為你收集整理的javac compiling error ( mising package)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vb.net VS2010编程
- 下一篇: Razor 也可说是一个asp.net模