java获取程序当前目录。
import java.net.URL;
import java.net.URLDecoder;
public class PathUtil
{
/**
* Get the env of windir, such as "C:\WINDOWS".
* @return the env of windir value.
*/
public static String getWindir(){
return System.getenv("windir");
}
/**
* Get file separator, such as "/" on unix.
*
* @return the separator of file.
*/
public static String getFileSeparator()
{
return System.getProperty("file.separator");
}
/**
* Get line separator, such as "\n" on unix.
*
* @return the separator of line.
*/
public static String getLineSeparator()
{
return System.getProperty("line.separator");
}
/**
* Get programPath
*
* @return programPath
*/
public static String getProgramPath()
{
Class<PathUtil> cls = PathUtil.class;
ClassLoader loader = cls.getClassLoader();
//
// Get the full name of the class.
//
String clsName = cls.getName() + ".class";
//
// Get the package that include the class.
//
Package pack = cls.getPackage();
String path = "";
//
// Transform package name to path.
//
if(pack != null)
{
String packName = pack.getName();
//
// Get the class's file name.
//
clsName = clsName.substring(packName.length() + 1);
//
// If package is simple transform package name to path directly,
// else transform package name to path by package name's
// constituent.
//
path = packName;
if(path.ind
相关文档:
JAVA可以通过JNI接口访问本地的动态连接库,从而扩展JAVA的功能。使用JAVA JNI接口主要包括以下步骤:
(1)编写JAVA代码,注明要访问的本地动态连接库和本地方法;
(2)编译JAVA代码得到.class文件;
(3)使用javah -jni 生成该类对应的C语言.h文件;
(4)使用C/C++实现(3)生成的.h文件中声明的各函数;
(5)编译C/ ......
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
在tomcat中发布web项目,可能是因为spring中配置了jndi(只配置了jndi,其他的有工具包封装了)。
启动的时候报错(在项目目录下,在tomcat中配置context指向项目目录就没问题,打包发布到
tomcat就报错了),抛的异常是:
jav ......
1.了解Java的原理:
首先要了解整个Java的大致结构、工作环境、历史。在这个过程中要搞明白Java从源代码到最后虚拟机里面执行的一个过程是怎样的。
2.学习Java语法:
Java里面只有50多个关键字和一些运算符。语法结构就只有顺序、条件、循环 ......
repaint 对组件进行重绘,比如一个panel,当你remove掉panel里面的一个组件时,你必须调用repaint方法才能对panel进行重绘,进行刷新,你想要删除的组件才能在界面上消失。
revalidate 对组件进行验证,比如一个panel,当你remove掉panel里面的一个组件时,当你调用revalidate方法后,panel的布 ......
事件源负责产生事件
事件类:定义事件的特征;
监听器接口:定义监听器应该实现的功能;
监听器:实现监听器接口,监听事件的发生并作出响应;
所有的事件类必须继承Java事件基类,即java.util.EventObject;EventObject(Object source)是EventObject唯一的构造方法,这意味着所有事件必须在实例化时就指定事件源 ......