public class HelloWorld{
public static void main(String[ ] args){
System.out.println(“Hi, Hello World!”);
}
}
|
Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
|
Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: HelloWorld
|
jar umf MANIFEST.MF hello.jar
|
java -jar hello.jar
|
Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: HelloWorld
|
Manifest-Version: 1.0
Class-Path: ./lib/msbase.jar ./lib/mssqlserver.jar ./lib/msutil.jar
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: org.qiujy.test.TestDB
|
package org.qiujy.test;
import java.sql.*;
public class TestDB{
public static void main(String[] args){
String url = "jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=myblog";
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection(url, "sa","");
System.out.println(conn);
}catch(Exception e){
e.printStackTrace();
}
}
}
|
javac -d . TestDB.java
|
Manifest-Version: 1.0
Class-Path: ./lib/msbase.jar ./lib/mssqlserver.jar ./lib/msutil.jar
Main-Class: org.qiujy.test.TestDB
|
jar -cmvf qiujyManifest.txt test.jar lib org
|
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
out.println("");
out.println("");
out.println("");
out.println("Hello, World!");
out.println("");
out.close();
}
}
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
|