博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
javac compiling error ( mising package)
阅读量:5316 次
发布时间:2019-06-14

本文共 6149 字,大约阅读时间需要 20 分钟。

javac 编译java源文件时,提示 package does not exist 的错误

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编译的时候报错!

解决办法:

  1. 到mvn repository()上面吧缺少的 jar 包下载下来,

  2. 然后给 CLASSPATH 环境变量在添加一下这个jar 包所在的路径,就可以了。

---------------------------------------------------------------------------------------

参考:

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 existimport org.apache.commons.codec.DecoderException;                               ^.\BaseCrypto.java:2: package org.apache.commons.codec.binary does not existimport org.apache.commons.codec.binary.Hex;                                      ^.\BaseCrypto.java:26: cannot find symbolsymbol  : class DecoderExceptionlocation: class BaseCrypto    public static byte[] asByte(String hexString) throws DecoderException {                                                         ^.\BaseCrypto.java:16: cannot find symbolsymbol  : variable Hexlocation: class BaseCrypto        return new String(Hex.encodeHex(buf));                          ^.\BaseCrypto.java:27: cannot find symbolsymbol  : variable Hexlocation: class BaseCrypto        return 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: 
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:

jurgen@Selena:~$ aptitude search commonsi libcommons-attributes-java - adds C#/.Net-style attributes to Java codei A libcommons-beanutils-java - utility for manipulating JavaBeans i libcommons-beanutils-java-doc - Javadoc API for libcommons-beanutils-java i A libcommons-cli-java - API for working with the command line argui A libcommons-codec-java - encoder and decoders such as Base64 and hei A libcommons-collections-java - A set of abstract data type interfaces andi A libcommons-collections3-java - A set of abstract data type interfaces andi libcommons-collections3-java-do - Documentation for libcommons-collections3-i libcommons-configuration-java - Java based library providing a generic conp libcommons-csv-java - a Java library for working with csv (commap libcommons-csv-java-doc - documentation for libcommons-csv-java i A libcommons-daemon-java - library to launch Java applications as daei A libcommons-dbcp-java - Database Connection Pooling Services i A libcommons-digester-java - Rule based XML Java object mapping tool p libcommons-discovery-java - locates classes that implement a given Javi A libcommons-el-java - Implementation of the JSP2.0 Expression Lai libcommons-fileupload-java - File upload capability to your servlets ani libcommons-httpclient-java - A Java(TM) library for creating HTTP clieni libcommons-httpclient-java-doc - Documentation for libcommons-httpclient-jai libcommons-io-java - Common useful IO related classes i libcommons-io-java-doc - Common useful IO related classes - documenp libcommons-jexl-java - expression language engine p libcommons-jxpath-java - manipulate javabean using XPath syntax p libcommons-jxpath-java-doc - Javadoc API for libcommons-jxpath-java i A libcommons-lang-java - Extension of the java.lang package i A libcommons-launcher-java - cross platform java application launcher i A libcommons-logging-java - commmon wrapper interface for several loggi A libcommons-modeler-java - convenience library to use Java Managementi libcommons-modeler-java-doc - documentation and examples for Commons Modi libcommons-net-java - internet protocol suite Java library p libcommons-openpgp-java - a common and simple interface for generatip libcommons-openpgp-java-doc - a common and simple interface for generatii A libcommons-pool-java - pooling implementation for Java objects i libcommons-validator-java - ease and speed development and maintenancep libgettext-commons-java - Java classes for internationalization (i18p libhibernate-commons-annotation - Hibernate Commons Annotations p libws-commons-util-java - Common utilities from the Apache Web Servip libxml-commons-resolver1.1-java - XML entity and URI resolver library p libxml-commons-resolver1.1-java - XML entity and URI resolver library -- docp libxml-commons-resolver1.1-java - XML entity and URI resolver library -- nati libxmlgraphics-commons-java - reusable components used by Batik and FOP

  

 

转载于:https://www.cnblogs.com/oxspirt/p/7443485.html

你可能感兴趣的文章
实验八 接口与实现接口的类
查看>>
简单的姓名号码查询系统
查看>>
PostgreSQL 保留关键字添加方法之一,不带参数的函数
查看>>
你的博客可能被爬了
查看>>
赛前热手 (天梯赛暴力题)
查看>>
.net 冒泡排序示例
查看>>
Uva(10330)
查看>>
vlan学习
查看>>
R-Sys.time计算程序运行时间
查看>>
【转贴】SAP HANA内存数据库详解
查看>>
两种应该掌握的排序方法--------1.shell Sort
查看>>
vuejs动态组件给子组件传递数据
查看>>
杭电2065(递推)红色病毒
查看>>
js 获取视频的第一帧
查看>>
各种正则验证
查看>>
观察者模式(Observer)
查看>>
python中numpy.r_和numpy.c_
查看>>
大道至简阅读笔记02
查看>>
WPF简单模拟QQ登录背景动画
查看>>
bzoj 2038 小Z的袜子
查看>>