码迷,mamicode.com
首页 > 其他好文 > 详细

JDK1.7目录分析

时间:2014-10-25 18:44:10      阅读:633      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   os   ar   使用   

在JDK1.7的根目录有bin,db,include,jre,lib五个文件夹,还有一个src.zip(Java的源码压缩包);其他的一些文件不做介绍..

bin:jdk/bin目录下基本都是.exe结尾的可执行文件:我们发现该目录下的文件都非常小,基本都是十几二十KB,是因为它们仅仅相当于一层代码的包装

这些工具的实现所要用到的类库都在tools.jar中,简单了解下各个exe文件的作用:

1:java.exe:java应用程序的启动器,

2:javac.exe:java语言编译器

3:javadoc.exe:java文档生成器

4:jvisualvm.exe:用来监控java运行程序的cpu、内存、线程等的使用情况

5:javap:class文件 反编译工具   

...

 

lib:jdk/lib目录存放的都是Java开发工具要用的一些库文件,个人感觉需要重点明白dt.jar和tools.jar的作用

dt.jar:dt.jar是关于运行环境的类库,主要是swing的包   在用到swing时最好加上。

tools.jar:首先上面说了jdk/bin目录下的exe工具许多实现都是在该jar包下,(自己可以去对照下),也就是说bin目录下的exe工具可以直接调用该jar包里面的class类

再就是tools.jar 是系统用来编译一个类的时候用到的,即执行javac的时候用到

    javac XXX.java

    实际上就是运行

    java -Calsspath=%JAVA_HOME%\lib\tools.jar xx.xxx.Main XXX.java

javac就是对上面命令的封装 所以tools.jar 也不用加到classpath里面

 

jdk/jre目录:This provides complete runtime support for Java applications(原文),提供java程序运行的全部环境,当我们打开jdk/jre/bin发现里面有很多.dll.exe文件,大部分与jdk/bin相似,例如:jdk\jre\bin\server\jvm.dll就是jvm运行所需要的DLL文件

 

jdk/jre/lib:该目录提供了JRE要用的代码库,属性设置,资源文件。其中就几个比较重要的JAR包:

1:rt.jar:rt.jar是JAVA基础类库,也就是你在java doc里面看到的所有的类的class文件,为java运行时所要的类的jar包,比如:java.io,java.util,由根classloader加载

2:charset.jar:字符装换,编码转换的jar包

3:ext文件夹:默认的Java平台扩展安装环境  ,包含localedata.jar 是 ava.text 和 java.util包要用到的地区数据 该目录下的类是由Extension ClassLoader来加载的

 

jdk/db目录,该目录应该是新加的,JDK6之后自带的微型数据库,这是一个纯 Java 实现、开源的数据库管理系统(DBMS)。

创建数据库:

bubuko.com,布布扣
 1 try { // load the driver 
 2             Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); 
 3             System.out.println("Load the embedded driver"); 
 4             Connection conn = null; 
 5             Properties props = new Properties(); 
 6             props.put("user", "user1");  props.put("password", "user1"); 
 7            //create and connect the database named helloDB  
 8             conn=DriverManager.getConnection("jdbc:derby:helloDB;create=true", props); 
 9             System.out.println("create and connect to helloDB"); 
10             conn.setAutoCommit(false); 
11  
12             // create a table and insert two records 
13             Statement s = conn.createStatement(); 
14             s.execute("create table hellotable(name varchar(40), score int)"); 
15             System.out.println("Created table hellotable"); 
16             s.execute("insert into hellotable values(‘Ruth Cao‘, 86)"); 
17             s.execute("insert into hellotable values (‘Flora Shi‘, 92)"); 
18             // list the two records 
19             ResultSet rs = s.executeQuery( 
20                 "SELECT name, score FROM hellotable ORDER BY score"); 
21             System.out.println("name\t\tscore"); 
22             while(rs.next()) { 
23                 StringBuilder builder = new StringBuilder(rs.getString(1)); 
24                 builder.append("\t"); 
25                 builder.append(rs.getInt(2)); 
26                 System.out.println(builder.toString()); 
27             } 
28             // delete the table 
29             s.execute("drop table hellotable"); 
30             System.out.println("Dropped table hellotable"); 
31              
32             rs.close(); 
33             s.close(); 
34             System.out.println("Closed result set and statement"); 
35             conn.commit(); 
36             conn.close(); 
37             System.out.println("Committed transaction and closed connection"); 
38              
39             try { // perform a clean shutdown  
40                 DriverManager.getConnection("jdbc:derby:;shutdown=true"); 
41             } catch (SQLException se) { 
42                 System.out.println("Database shut down normally"); 
43             } 
44         } catch (Throwable e) { 
45             // handle the exception 
46         } 
47         System.out.println("SimpleApp finished")
View Code

pom依赖:

bubuko.com,布布扣
1 <dependency> 
2             <groupId>org.apache.derby</groupId> 
3             <artifactId>derby</artifactId> 
4             <version>10.6.1.0</version> 
5             <scope>test</scope> 
6 </dependency> 
View Code

 

 

 

上面的知识由自己参考了一些博客加以整理实践得出,可能会有一些错误,敬请谅解。

 

JDK1.7目录分析

标签:des   style   blog   http   color   io   os   ar   使用   

原文地址:http://www.cnblogs.com/alwayshelloworld/p/4050370.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!