블로그 이미지

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
  • total
  • today
  • yesterday
2014. 1. 18. 17:12 JAVA언어/applet

<dependency>
    <groupId>sun.plugin</groupId>
    <artifactId>plugin</artifactId>
    <version>1.6</version>
    <scope>system</scope>
    <systemPath>C:\Java\jre6/lib/plugin.jar</systemPath>
 </dependency>

posted by 천상의날개
2014. 1. 18. 17:10 JAVA언어/applet

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.test</groupId>
 <artifactId>applet</artifactId>
 <version>0.0.1-SNAPSHOT</version>
 <dependencies>
  <dependency>
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>httpclient</artifactId>
   <version>4.3.1</version>
  </dependency>
  <dependency>
   <groupId>sun.plugin</groupId>
   <artifactId>plugin</artifactId>
   <version>1.6</version>
   <scope>system</scope>
   <systemPath>${java.home}/lib/plugin.jar</systemPath>
  </dependency>
 </dependencies>
 <build> 

  <plugins>   
   <plugin>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
     <archive>
      <addMavenDescriptor>false</addMavenDescriptor>
     </archive>
    </configuration>
   </plugin>  
   
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2.1</version>
    <configuration>
     <descriptorRefs>
      <descriptorRef>jar-with-dependencies</descriptorRef>
     </descriptorRefs>
     <outputDirectory>${basedir}\..\appletTest\WebContent\applet\</outputDirectory>     
     <finalName>applet</finalName>
     <appendAssemblyId>false</appendAssemblyId>
    </configuration>
    <executions>
     <execution>
      <id>make-assembly</id> <!-- this is used for inheritance merges -->
      <phase>package</phase> <!-- bind to the packaging phase -->
      <goals>
       <goal>single</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
   
   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jarsigner-plugin</artifactId>
    <version>1.3</version>
    <executions>
     <execution>
      <id>sign</id>
      <goals>
       <goal>sign</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <keystore>${basedir}\src\main\resources\test.keystore</keystore>
     <alias>testalias</alias>
     <storepass>testpss</storepass>
     <keypass>testpss</keypass>
    </configuration>
   </plugin>
  </plugins>
 </build>
</project>

posted by 천상의날개
2013. 7. 2. 19:49 JAVA언어

상위 버전의 JVM에서 컴파일된 클래스를 하위 버전의 JVM에 실행시킬 경우

java.lang.UnsupportedClassVersionError 가 발생을 한다.

(물론 하위버전의 JVM에서 컴파일된 클래스는 상위버전의 JVM에 실행됨)

 

1. JDK별 Java Class Version

    JDK 1.6 => 50.0  (32H)
    JDK 1.5 => 49.0  (31H)
    JDK 1.4 => 48.0  (30H)
    JDK 1.3 => 47.0  (2fH)

 

   참고로 JDK 1.4.2 (다른 버전의 경우는?) 에서 컴파일된 클래스의 경우는 호환성 유지를 위해

   Class Version이 46 (2eH)으로 표시됨

 

2. Class파일의 버전 확인 방법 (Hex Editor로 확인)

    UltraEditor등의 Hex Editor를 이용하여 클래스파일을 직접 확인

 

    00000000h: CA FE BA BE 00 00 00 31 00 69 0A 00 21 00 2E 0A

 

    - CA FE BA BE : Java Class라는 Magic Number

    - 31: Java Class Version (10진수로 49 -> JDK 1.5)  

   

3. Class파일의 버전 확인 방법 (javap 로 확인)

   JDK의 javap 커맨드를 이용하여 major version 확인

 

   C:\>javap -verbose test
   Compiled from "test.java"
   class test extends java.lang.Object
      SourceFile: "test.java"
      minor version: 0
      major version: 49
      Constant pool:

 

http://ecspecialist.tistory.com/entry/Java-Class-%EB%B2%84%EC%A0%84-%ED%99%95%EC%9D%B8-%EB%B0%A9%EB%B2%95

에서 펌

'JAVA언어' 카테고리의 다른 글

자바 예외 String으로 저장  (0) 2016.02.03
web.xml 에 context-param에값넣고 빼오기  (0) 2015.02.09
File 전송, io  (0) 2012.06.28
jstl 설정방법  (0) 2012.04.09
java 7의 기능 모음  (1) 2012.03.07
posted by 천상의날개
2012. 6. 28. 20:33 JAVA언어
파일전송

'JAVA언어' 카테고리의 다른 글

web.xml 에 context-param에값넣고 빼오기  (0) 2015.02.09
Class의 컴파일된 자바 버전 확인 하는 방법  (0) 2013.07.02
jstl 설정방법  (0) 2012.04.09
java 7의 기능 모음  (1) 2012.03.07
간단한 Enum 사용법  (0) 2011.12.21
posted by 천상의날개
2012. 4. 9. 21:02 JAVA언어

c.tldfmt.tldjstl-api-1.2.jarjstl-impl-1.2.jarmysql-connector-java-5.1.18-bin.jarweb.xml

c.tld fmt.tld jstl-api-1.2.jar jstl-impl-1.2.jar 파일은 WebContent/WEB-INF/lib에

web.xml은 WebContent/WEB-INF/에 복사한다.

그리고 jsp 페이지에서는

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

를 추가한다.

 

maven

<dependency>
         <groupId>taglibs</groupId>
         <artifactId>datetime</artifactId>
         <version>1.0.1</version>
     </dependency>       
     <dependency>
         <groupId>taglibs</groupId>
         <artifactId>string</artifactId>
         <version>1.1.0</version>
     </dependency>       
     <dependency>
         <groupId>taglibs</groupId>
         <artifactId>standard</artifactId>
         <version>1.1.2</version>
     </dependency>
     <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>1.1.2</version>

'JAVA언어' 카테고리의 다른 글

Class의 컴파일된 자바 버전 확인 하는 방법  (0) 2013.07.02
File 전송, io  (0) 2012.06.28
java 7의 기능 모음  (1) 2012.03.07
간단한 Enum 사용법  (0) 2011.12.21
quick sort  (0) 2011.12.21
posted by 천상의날개
2012. 3. 7. 11:21 JAVA언어
1. Null의 체크
기존 null 체크 소스
java 7의 소스



2. String 으로 switch case 문을 판단가능
java 7의 case 문


3. Exception 모음기능
java 7의 소스
4. <>의 간략화
java 7의 소스


5. 숫자표현(2진수는 0b가 붙음) java 7의 소스


6.try-catch 자원관리
java 7의 소스
해당 코드는 try구문이 끝나면 자동으로 해당 변수에 대한 close를 호출한다. 자동으로 회수되어져야 하는 자원들은 내부적으로 java.lang.AutoCloseable 인터페이스를 구현해야 한다. 구현한 close 메소드는 try블럭을 나왔을때 JVM에 의해 자동적으로 호출된다.

7.새로운 파일시스템 nio 2.0의 추가 File Change Notifications 기능이 있음.

8.병렬 코어를 위한 Fork와 Join기능

참조 싸이트
http://www.hanb.co.kr/network/view.html?bi_id=1780 (Nio 2.0, fork Join)
http://metoojava.wordpress.com/2010/11/15/java-7-awesome-features/

'JAVA언어' 카테고리의 다른 글

File 전송, io  (0) 2012.06.28
jstl 설정방법  (0) 2012.04.09
간단한 Enum 사용법  (0) 2011.12.21
quick sort  (0) 2011.12.21
MySQL JDBC INSERT 시 AUTO INCREMENT 값을 알아내는 예제  (0) 2011.10.05
posted by 천상의날개
2011. 12. 21. 13:05 JAVA언어
public class  SortingService{
 private SortingAlgorithm sortingAlgorithm; 
 
 public enum SortState{
  QUICK,BUBBLE
 } 
 public SortState state;  

}

'JAVA언어' 카테고리의 다른 글

jstl 설정방법  (0) 2012.04.09
java 7의 기능 모음  (1) 2012.03.07
quick sort  (0) 2011.12.21
MySQL JDBC INSERT 시 AUTO INCREMENT 값을 알아내는 예제  (0) 2011.10.05
String 컴파일  (0) 2011.08.05
posted by 천상의날개
2011. 12. 21. 12:46 JAVA언어

갑자기 왠 퀵 정렬이냐 라곤 하지만,

그나마 정렬에선 퀵 정렬이 빠르고 그만큼 저도 자주 애용하는 정렬 기법입니다.

정리해 두었다가 필요할 때 잽싸게 훑어볼 목적으로 글을 남깁니다. 크크크.

먼저 정렬을 할 배열 중에서 어느 기준의 값을 하나 정합니다. 우리는 그것을 pivot(중심축)이라고 하죠.

그리고 배열의 왼쪽으로부터 검색하여(iLow) 배열의 값이 pivot보다 크거나 같은 값의 인덱스를 찾습니다.

역시 그 배열의 오른쪽으로부터 검색하여(iHigh) 배열의 값이 pivot보다 작은 값의 인덱스를 찾습니다.

-임의로 결정한 pivot은 5. 왼쪽 인덱싱의 값은 1, 오른쪽 인덱싱의 값은 8-

둘이 가리키는 데이터를 교체합니다.

이어서 같은 방식으로 계속 검색해 나갑니다.

- 0와 9를 교체-

그러다가 iLow와 iHigh가 엇갈리는 순간이 되면, pivot의 값과 iHigh의 값을 교체해 줍니다.

-pivot값 5와 iHigh의 4의 값과 교체-

여기까지 정렬의 1단계가 끝. 이제부터 분할 정복이 시작됩니다.

분할 정복에 대해 간단히 설명하자면,

배열의 범위를 마지막 iHigh의 인덱스를 기준으로 쪼개서 나눠진 둘의 범위에 대해 위의 과정을 반복하는 것이지요.

-1단계 마지막 iHigh 값을 기준으로 두 범위로 나눠서 각각 1단계를 적용-

 

-2단계 후. 이 예에서는 각각의 분할 축의 위치가 한쪽에 치우쳐 있어서 더 이상 분할되지가 않는다-

-3단계 후-

-4단계 후. 정렬 완료-

아래는 소스입니다. 주석이 있으니 이해하기엔 충분할 겁니다. (파일 첨부)

// pArray : 데이터가 들어있는 배열
// iLow_ : 정렬할 범위의 최하 인덱스
// iHigh_ : 정렬할 범위의 최상 인덱스


template< typename T >
void quick_sort( T* pArray, int iLow_, int iHigh_ ) {

//인덱스 점검
if( iLow_ >= iHigh_ ) {
return ;
}

int iLow, iHigh; //인덱스
int pivot; //비교할 기준 값

iLow = iLow_;
iHigh = iHigh_ + 1;
pivot = pArray[ iLow_ ]; //기준 데이터는 최하 인덱스의 데이터로

do {

//교체할 데이터 위치를 찾는다.

do {
}while( pArray[ ++iLow ] < pivot );

//교체할 데이터 위치를 찾는다.

do {
}while( pArray[ --iHigh ] > pivot );

//기준보다 큰 데이터와 적은 데이터를 서로 교환
if( iLow < iHigh ) {

// pArray[ iLow ] ^= pArray[ iHigh ] ^= pArray[ iLow ] ^= pArray[ iHigh ]; //Swap! only integer, short available

T temp = pArray[ iLow ];

pArray[ iLow ] = pArray[ iHigh ];

pArray[ iHigh ] = temp;
}else {
break;
}

}while( TRUE );

//정렬 후, pivot과 iHigh 교체

pArray[ iLow_ ] = pArray[ iHigh ];
pArray[ iHigh ] = pivot;

//분할 정복
quick_sort( pArray, iLow_, iHigh - 1 );
quick_sort( pArray, iHigh + 1, iHigh_ );

}//void quick_sort


[출처]
Quick Sort ( 퀵 정렬 )|작성자 Hermet

Change JAVA


public List<Integer> sort(List<Integer> target) {
  List<Integer> returnValue = new ArrayList<Integer>(target);
  
  quickSort(returnValue,0,returnValue.size()-1);

  return returnValue;
 }

private void quickSort(List<Integer> target, int iLow_, int iHigh_) {
  
  if (iLow_ >= iHigh_) {
   return;
  }

  int iLow, iHigh;
  int pivot;

  iLow = iLow_;
  iHigh = iHigh_ + 1;
  pivot = target.get(iLow_);

  do {


   do {
   } while (target.get(++iLow) < pivot);


   do {
   } while (target.get(--iHigh) > pivot);

   if (iLow < iHigh) {


    int temp = target.get(iLow);

    target.set(iLow,target.get(iHigh));

    target.set(iHigh,temp);
   } else {
    break;
   }

  } while (true);

  target.set(iLow_,target.get(iHigh));
  target.set(iHigh,pivot);

  quickSort(target, iLow_, iHigh - 1);
  quickSort(target, iHigh + 1, iHigh_);
 }

'JAVA언어' 카테고리의 다른 글

java 7의 기능 모음  (1) 2012.03.07
간단한 Enum 사용법  (0) 2011.12.21
MySQL JDBC INSERT 시 AUTO INCREMENT 값을 알아내는 예제  (0) 2011.10.05
String 컴파일  (0) 2011.08.05
싱글톤 생성법(늦은 생성)  (0) 2011.04.27
posted by 천상의날개
2011. 10. 5. 21:27 JAVA언어

다음은 MySQL JDBC INSERT 시 AUTO INCREMENT 값을 알아내는 예제이다.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MySQLJdbcExample {

public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

String url = "jdbc:mysql://localhost:3306/test";
String username = "root";
String password = "apmsetup";
try {
Connection conn = DriverManager.getConnection(url, username, password);
Statement stmt = conn.createStatement();

String sql = "INSERT INTO auto_increment_test_table (name) VALUE ('test')";
stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);

ResultSet rs = stmt.getGeneratedKeys();
if (rs.next()) {
int autoIncrement = rs.getInt(1);
System.out.println("autoIncrement: " + autoIncrement);
}

}

위 예제는 JDBC의 기능을 활용한 버전이었고,

이번에는 MySQL의 SQL 문을 활용하는 버전이다.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class MySQLJdbcExample {

public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

String url = "jdbc:mysql://localhost:3306/test";
String username = "root";
String password = "apmsetup";
try {
Connection conn = DriverManager.getConnection(url, username, password);
Statement stmt = conn.createStatement();

String sql = "INSERT INTO auto_increment_test_table (name) VALUE ('test')";
stmt.executeUpdate(sql, Statement.RETURN_GENERATED_KEYS);

ResultSet rs = stmt.getGeneratedKeys();
if (rs.next()) {
int autoIncrement = rs.getInt(1);
System.out.println("autoIncrement: " + autoIncrement);
}

sql = "SELECT LAST_INSERT_ID()";
rs = stmt.executeQuery(sql);
if (rs.next()) {
int autoIncrement = rs.getInt(1);
System.out.println("autoIncrement: " + autoIncrement);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}
http://devday.tistory.com/304 에서 펌

'JAVA언어' 카테고리의 다른 글

간단한 Enum 사용법  (0) 2011.12.21
quick sort  (0) 2011.12.21
String 컴파일  (0) 2011.08.05
싱글톤 생성법(늦은 생성)  (0) 2011.04.27
exepiton message printStackTrace처럼 찍기  (0) 2011.04.16
posted by 천상의날개
2011. 8. 5. 19:37 JAVA언어
CompilerTest.java
StringCompiler.java
Test.java

'JAVA언어' 카테고리의 다른 글

quick sort  (0) 2011.12.21
MySQL JDBC INSERT 시 AUTO INCREMENT 값을 알아내는 예제  (0) 2011.10.05
싱글톤 생성법(늦은 생성)  (0) 2011.04.27
exepiton message printStackTrace처럼 찍기  (0) 2011.04.16
data DownLoad 코드  (0) 2011.02.09
posted by 천상의날개