javac compiling error ( mising package)

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(http://mvnrepository.com/artifact/commons-codec/commons-codec/1.7)上面吧缺少的 jar 包下载下来,

  2. 然后给 CLASSPATH 环境变量在添加一下这个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:

jurgen@Selena:~$ aptitude search commons
i libcommons-attributes-java - adds C#/.Net-style attributes to Java code
i 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 argu
i A libcommons-codec-java - encoder and decoders such as Base64 and he
i A libcommons-collections-java - A set of abstract data type interfaces and
i A libcommons-collections3-java - A set of abstract data type interfaces and
i libcommons-collections3-java-do - Documentation for libcommons-collections3-
i libcommons-configuration-java - Java based library providing a generic con
p libcommons-csv-java - a Java library for working with csv (comma
p libcommons-csv-java-doc - documentation for libcommons-csv-java 
i A libcommons-daemon-java - library to launch Java applications as dae
i 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 Jav
i A libcommons-el-java - Implementation of the JSP2.0 Expression La
i libcommons-fileupload-java - File upload capability to your servlets an
i libcommons-httpclient-java - A Java(TM) library for creating HTTP clien
i libcommons-httpclient-java-doc - Documentation for libcommons-httpclient-ja
i libcommons-io-java - Common useful IO related classes 
i libcommons-io-java-doc - Common useful IO related classes - documen
p 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 logg
i A libcommons-modeler-java - convenience library to use Java Management
i libcommons-modeler-java-doc - documentation and examples for Commons Mod
i libcommons-net-java - internet protocol suite Java library 
p libcommons-openpgp-java - a common and simple interface for generati
p libcommons-openpgp-java-doc - a common and simple interface for generati
i A libcommons-pool-java - pooling implementation for Java objects 
i libcommons-validator-java - ease and speed development and maintenance
p libgettext-commons-java - Java classes for internationalization (i18
p libhibernate-commons-annotation - Hibernate Commons Annotations 
p libws-commons-util-java - Common utilities from the Apache Web Servi
p libxml-commons-resolver1.1-java - XML entity and URI resolver library 
p libxml-commons-resolver1.1-java - XML entity and URI resolver library -- doc
p libxml-commons-resolver1.1-java - XML entity and URI resolver library -- nat
i libxmlgraphics-commons-java - reusable components used by Batik and FOP

  

 

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/282596.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

使用ffmpeg录音

官方教程:http://ffmpeg.org/ffmpeg.html 录音方法: 开始找到了这个方法,但是不行呀,好像是没有这个oss吧。 oss 是linux 下的声音相关的东西,与alsa 一样,不过oss 是商业的, 而/dev/dsp 是oss …

Mysql慢查询日志的使用 和 Mysql的优化

一、生成实验数据 原理:sql 蠕虫复制(这种生成数据方式同样适用于数据表中有主键的情况)。 insert into comic (name,pen_name,cover) select name,pen_name,cover from comic 二、慢查询日志设置 当语句执行时间较长时,通过日…

Oracle 12C CDB、PDB常用管理命令

--查看PDB信息(在CDB模式下) show pdbs --查看所有pdb select name,open_mode from v$pdbs; --v$pdbs为PDB信息视图 select con_id, dbid, guid, name , open_mode from v$pdbs; --切换容器 alter session set containerorcl1 --切换到PDBorcl1容器…

指定时间的月初和月末一天的写法

DateTime dt Convert.ToDateTime("2017-2");DateTime FirstDay new DateTime(dt.Year, dt.Month, 1);//本月初1號DateTime LastDay new DateTime(dt.AddMonths(1).Year, dt.AddMonths(1).Month, 1).AddDays(-1);//下月初1號減一天本月底 转载于:https://www.cnblo…

mysql数据表设计要点以及快门

一个sql表的设计首先要考虑的是字段 然后去考虑这个字段应该具有哪些特性, 最后,考虑哪些字段经常用于查询,设置为索引 下面是一个比较简单的例子,大概说明了怎么样去构造sql语句创建一个sql表 create table user_message( id int UNSIGNED not null auto_increment COMMEN…

分享实录|区块链技术与智能合约入门(开发实例)

1 什么是区块链 1.1白话讲解区块链 现在区块链特别火,可能大家都听说过区块链,听说过比特币,那到底什么是区块链? 前几天和一个朋友撸串,我给他安利区块链和比特币以及一些数字货币的知识,这个朋友也是一个…

大型网站技术架构:核心原理与案例分析笔记

1.大型网站软件系统的特点: 高并发,大流量  高可用 海量数据  用户分布广泛,网络情况复杂  安全环境恶劣  需求快速变更,发布频繁  渐进式发展  2.大型网站演变架构 1)初步应用:数据(数据…

1777:文件结构“图”

1777:文件结构“图” 查看提交统计提问总时间限制: 1000ms内存限制: 65536kB描述在计算机上看到文件系统的结构通常很有用。Microsoft Windows上面的"explorer"程序就是这样的一个例子。但是在有图形界面之前,没有图形化的表示方法的,那时候最…

thinkphp出现Call to undefined function Think\C() in ... online 313

造成这个问题的原因很多,在这里我只说明我自己遇到之后解决的办法 我将functions.php改成了function.php之后,修改了一些其他无关紧要的东西出现了这个问题,来回排查,各种尝试,最后,将function.php改回functions.php,可以正常运行

Oracle数据库IP访问限制(IP白名单黑名单)

1、编辑sqlnet.ora内容为:#允许访问的IP(白名单)TCP.INVITED_NODES(127.0.0.1,192.168.56.109,ip2,ip3,..,..本地IP..)若使用白名单,必须有本地IP,否则监听会起不来#不允许访问的IP(黑名单)#TCP…

WPF效果第一百九十九篇之Gamma曲线

前面效果中分享了模块对比;今天大周末那就再来分享一下最近实现的效果;基于YX^n公式根据不同的系数绘制Gamma曲线效果如下图:1、曲线的话,咱就用最简单的方式绘制一堆点:PathFigure pathFigure new PathFigure(){StartPoint new Point(0, count),};for(double x 0; x < 1…

图片序列化和反序列化成图片文件(代码)

// // ViewController.m // 图片序列化和反序列化 // // Created by Qlinchao on 17/3/14. // Copyright © 2017年 QLC. All rights reserved. //#import "ViewController.h"interface ViewController () property (weak, nonatomic) IBOutlet UIImageView …

windows 下 MyEclipse 逆向工程生成hiberate 对应配置文件以及 javaBean。

步骤1&#xff1a; 右边工具栏 -> 右击你的项目 -> 选中 MyEclipse -> Project Facets -> install Hibernate Facet -> 选择对应的版本&#xff08;以及一些你想要的配置&#xff09; 步骤2&#xff1a; 导航栏 -> window -》 show View -> Other 。 然…

php加解密

一 对称加密 1.mycyrpt的对称加密: /*** param $key //数据加密密钥 由自己定义,长度有限制 string* param $string //需要进行加解密的字符串 string* param $decrypt //加密还是解密 (最简单的,0代表加密,1代表解密)* return string*/ function encryptDecrypt($key, $st…

深入理解Spring Boot数据源与连接池原理

​ Create by ysterfoxmail.com 2018-8-2一&#xff1a;开始 在使用Spring Boot数据源之前&#xff0c;我们一般会导入相关依赖。其中数据源核心依赖就是spring‐boot‐starter‐jdbc 如下 <dependency><groupId>org.springframework.boot</groupId> …

Dapr 集成 Open Policy Agent 实现 接口的访问控制

大型项目中基本都包含有复杂的访问控制策略&#xff0c;特别是在一些多租户场景中&#xff0c;例如Kubernetes中就支持RBAC&#xff0c;ABAC等多种授权类型。Dapr 的 中间件 Open Policy Agent 将Rego/OPA策略应用到传入的Dapr HTTP请求中。Open Policy AgentOpen Policy Agent…

【Java】BigDecimal

一、前言 在使用Java&#xff0c;double 进行运算时&#xff0c;经常出现精度丢失的问题&#xff0c;总是在一个正确的结果左右偏0.0000**1。 特别在实际项目中&#xff0c;通过一个公式校验该值是否大于0&#xff0c;如果大于0我们会做一件事情&#xff0c;小于0我们又处理其他…

PHP获取当前页面URL

//获取页面url function curPageURL() {$pageURL http;if (!empty($_SERVER[HTTPS])) {$pageURL . "s";}$pageURL . "://";if ($_SERVER["SERVER_PORT"] ! "80") {$pageURL . $_SERVER["SERVER_NAME"].":".$_SER…

【招聘(大连)】北森云计算 .NET 专场招聘

为了更好的实现战略布局&#xff0c;逐步形成以三个产品研发中心&#xff08;北京、成都、大连&#xff09;为主&#xff0c;青岛和南京为辅的产品研发团队配置。北森云第三研发中心&#xff08;大连&#xff09;正式成立&#xff0c;目前大连的人选招聘正式开启&#xff0c;欢…

PHP强制下载文件

//有时我们不想让浏览器直接打开文件&#xff0c;如PDF文件&#xff0c;而是要直接下载文件&#xff0c;那么以下函数可以强制下载文件 //函数中使用了application/octet-stream头类型。 function downloads($filename,$dir./) {$filepath $dir.$filename;if (!file_exists($f…