易截截图软件、单文件、免安装、纯绿色、仅160KB

java路径

import java.io.File;
/**
* @description <p>java 路径</p>
* @author swandragon
* @date Nov 5, 2009
*/
public class FilePath{
/**
* 开发中不要使用System.getProperty("user.dir")获取当前用户目录的相对路径
* 也尽可能不要使用绝对路径,使用绝对路径时可以在配置文件中配置,项目中读取配置文件
* 应尽可能的使用相对路径,推荐使用当前类的classpath的URI目录路径
* 使用相对于classpath的路径而不是相对于源文件的路径,因为项目运行的是类文件
*/
public static void main(String[] args){
//用户当前工作目录,绝对路径
System.out.println(System.getProperty("user.dir"));

//java类路径 ,包括路径中的jar包
System.out.println(System.getProperty("java.class.path"));

//加载库时搜索路径(jdk bin目录,当前目录,系统目录\WINDOWS;\WINDOWS\system32,环境变量path目录)
System.out.println(System.getProperty("java.library.path"));

//用户当前目录 (项目跟目录绝对路径)
File file = new File("");
System.out.println(file.getAbsolutePath());

//用户当前目录 (项目跟目录绝对路径)
file = new File(".");
System.out.println(file.getAbsolutePath());

//用户当前目录 (项目跟目录绝对路径)
file = new File(".\\");
System.out.println(file.getAbsolutePath());

//用户当前目录的上级目录 (项目跟目录绝对路径的上级目录)
file = new File("..");
System.out.println(file.getAbsolutePath());

//用户当前目录的上级目录 (项目跟目录绝对路径的上级目录)
//(..\\images) images与当前目录的上级目录为同级目录
file = new File("..\\");
System.out.println(file.getAbsolutePath());


//当前类FilePath的类文件的URI目录 包括FilePath类所在的包
System.out.println(FilePath.class.getResource(""));
//当前类的classpath的URI目录
System.out.println(FilePath.class.getResource("/"));
//当前类的classpath的URI目录
System.out.println(FilePath.class.getClassLoader().getResource(""));
//当前类的classpa


相关文档:

Java异常处理总结

 转至:http://sllereak.blog.163.com/blog
--异常
 *异常是java提供的处理程序中运行时错误的一种机制
 *java程序在执行过程中如果出现异常,会生成一个异常类实例,该实例封装了异常的信息交给java运行时系统,这一过程叫抛出异常
 *当异常抛出时如果没有捕获那么java运行时默认的处理方式是将异 ......

我的java学习日记

  在大部分自学的情况下,学习java已快有一年了,最近看了一下jdk中demo下的Clock小程序,在温习了一下Applet的同时,也学到了不少新东西。首先,Applet的基本骨架是由:init(),start(),stop(),destroy(),paint(Graphics g),repaint()和update()这几个方法构成的。
  init()用来初始化实例,start()用来起动程序 ......

java第5天的代码

/*****************Animal.java begin ***********************/
 public class Animal{
 
 public void jj(){
  
 }
 
 public static void main(String args[]){
  //编译时类型       //运行时类型
  Animal anima ......

在Ubuntu搭建java开发环境

这里的说的java开发环境,以搭建eclipse3.2.1为主题.
  1、安装好Ubuntu系统;安装的时候强烈建议连接上网,它会自动下载语言包,自动装上五笔,拼音,还有会默认把firefox浏览器设置为中文.
  安装Ubuntu比windows系统一个比较爽地方就是安装可以一边上网浏览,还可以试用一下Ubuntu的功能。
  2、配置Ubuntu环境: ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号