Tuesday 24 July 2007

dos command - javac -classpath

If you want to specify two classpath file,

javac -classpath equinox.jar;MoviesInterface.jar osgitut/movies/impl/*.java

Sunday 22 July 2007

Basic - OSGI programming

http://neilbartlett.name/blog/osgi-articles/

http://www.eclipsezone.com/eclipse/forums/t90365.html

Wednesday 18 July 2007

basic concept of Ant

first : http://www.javastudy.co.kr/docs/lec_oop/ant/ant1.htm

second : http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html

Wednesday 11 July 2007

JDK version confilict

** Error Message **

Generated servlet error:
bad class file: C:\Program Files\Java\jre1.5.0_04\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public final class write_jsp extends org.apache.jasper.runtime.HttpJspBase


*** Reason ***
Installed JDK 1.4 and JDK 1.5 and it is conflicted.

*** Solution ***
Please clear JDK 1.4 and JDK 1.5
(Remove JDK 1.4 and Reinstall JDK 1.5)

1 open regedit
2 HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment > defined VM
3 delete all key under JavaSoft
4 And reinstall JDK

- Also tomcat has the location for VM...

Also you have to change jre setting. It should be a JDK folder (ex : C:\Program Files\Java\jdk1.5.0_12\jre)
this plugin launches Tomcat using the default JRE checked in Eclipe preferences window. To set a JDK as default JRE for Eclipse open the preference window : Window -> Preferences -> Java -> Installed JREs.
This JRE must be a JDK (This is a Tomcat prerequisite).

** Study **
Q)
자바 프로그램을 만들고 도스 상에서 java 라고 명령을 치는데요.
제가 path 나 classpath 등 환경변수를 모두 삭제하고 해봤거든요.
그런데 다른건 다 안되는데 java 명령은 실행이 되는 겁니다.

그래서 이번엔 program files\java\ ... 안의 jvm.dll 파일을 삭제하고
java 명령을 내려보니까
program files\java\bin\client 안에 jvm.dll 이 없어서 실행이 안된다는
메세지가 나오더라구요.

그래서 아! java 명령은 자바 런타임 환경(Jre) 하고 관련이 있는가
싶거든요. 그런데 java.exe 파일이 path 설정된 것도 아닌데
왜 어떻게 program files 안의 Jre 와 관련이 있는지 이해가 안갑니다.

A)
가장 정확하게 아실려면... src.zip 파일을 열어서 그 안에 launcher 폴더 내의 c 코드를 분석하면 가장 잘 이해할 수 있습니다...

일단 java.exe가 자바 바이너리를 구동하기에는 가장 먼저 jvm.dll이 필요하구요 그리고 해당 몇 가지 추가적인 dll 그리고 API들의 바이너리를 가지고 있는 jar 또는 zip 파일들이 필요합니다...

저두 정확하게 무엇이 필요하며 무엇이 필요없는지 알 수 없습니다... ㅡ.ㅡ;;

일단 java_md.c 파일을 잠깐 분석해보면... jvm.dll을 찾기 위해 그리고 Java_Home을 찾기 위해 Windows일 경우에는 레지스트리를 찾아갑니다... 기본적으로

HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment

아래의 CurrentVersion이라는 이름의 값을 봅니다.. 저는 현재 1.4입니다. 그리면 그 아래 키로 1.4가 있는지 찾죠.. 그 키 아래 Java_Home이라는 이름의 값을 봅니다... 있다면 이것이 Java_Home으로 인식합니다.. 저의 경우에는..

C:\Program Files\Java\j2re1.4.2_02

이였습니다...

다음은 .. jvm.dll을 찾습니다.. 먼저 Java_Home 아래의 lib 디렉토리를 찾습니다. 그리고 Windows일 경우 i386이라는 디렉토리 아래에 jvm.cfg를 살펴봅니다... 제경우 그 파일안에 다음과 같이 적혀 있습니다..

-client KNOWN
-server KNOWN
-hotspot ALIASED_TO -client
-classic WARN
-native ERROR
-green ERROR

여기서 jvm의 이름 또는 참조 장소를 말하고 있습니다... KNOWN은 아마 존재한다 또는 사용할 수 있다라는 의미인듯하구요... WARN이나 ERROR인 경우는 오류를 내겠다는 의미인듯합니다... 그리고 ALIAED_TO는 별칭된 이름과 동일하다라는 의미입니다...

위 목록중에서 가장 빠른 KNOWN으로 설정된 jvm이 선택됩니다... 여기선 client이죠 그러면 Java_Home 아래 bin 아래 client 디렉토리에 있는 jvm.dll이 jvm으로 로딩되고 그리고 JNI를 사용하여 해당 main class를 로딩하여 main함수를 호출합니다...

앗 그리고 jvm이 로딩되기 이전에 classpath와 여러가지 옵션등이 추가되게 됩니다...

Monday 2 July 2007

How you can use ObJectRelationalBridge – OJB

Apache ObJectRelationalBridge (OJB) is an Object/Relational mapping tool that allows transparent persistence for Java Objects against relational databases.

Main Web site
http://db.apache.org/ojb/

Download File

Sunday 1 July 2007

Converter between XML Object and String Object

=== From Body ===
var xmlStringConverterObj = new xmlStringConverter();
var metaData_String = xmlStringConverterObj.xmlToString(this is xml object location);

==== From JS File ===

xmlStringConverter = function () {

this.browserOption = "";
if (window.ActiveXObject) {
this.browserOption = 0;
} else {
this.browserOption = 1;
}
}

xmlStringConverter.prototype = {

xmlToString: function(xmlObj) {
var result = "";
if (this.browserOption == 0)
{
result = xmlObj.xml;
} else {
result = (new XMLSerializer()).serializeToString(xmlObj);
}
return result;
},

stringToXml: function(stringObj) {
var result;
var xmlObj;

if (this.browserOption == 0)
{
xmlObj = new ActiveXObject("Microsoft.XMLDOM");
xmlObj.async = false;
xmlObj.loadXML(stringObj);
} else {
var parser=new DOMParser();
xmlObj = parser.parseFromString(stringObj,"text/xml");
}
return xmlObj;
}
}

Javascript Modal Window

This javascript modal window is working under IE, Firefox, Nescape.

=== From Body ====
window.modal("SaveAsXML.htm", "height=270,width=460,toolbars=0,resizable=0,top=200,left=100");


=== From JS File ====
function modal(url,feature)
{
dialog(url,"",feature,true);
return false;
}

function dialog(url,name,feature,isModal)
{
if(url==null){return false;}
url = url
if(name==null){name=""}
if(feature==null){feature=""};
if(window.showModelessDialog)
{
var WindowFeature = new Object();
WindowFeature["width"] = 400;
WindowFeature["height"] =400;
WindowFeature["left"] = "";
WindowFeature["top"] = "";
WindowFeature["resizable"] = "";

if(feature !=null && feature!="")
{
feature = ( feature.toLowerCase()).split(",");

for(var i=0;i< feature.length;i++)
{
if( feature[i].isArgument())
{
var featureName = feature[i].split("=")[0];
var featureValue = feature[i].split("=")[1];

if(WindowFeature[featureName]!=null){WindowFeature[featureName] = featureValue; }
}
}
}

if(WindowFeature["resizable"]==1 || WindowFeature["resizable"]=="1" || WindowFeature["resizable"].toString().toLowerCase()=="yes"){WindowFeature["resizable"] = "resizable:1;minimize:1;maximize:1;"}
if(WindowFeature["left"]!=""){WindowFeature["left"] ="dialogLeft:" + WindowFeature["left"] +"px;";}
if(WindowFeature["top"]!=""){WindowFeature["top"] ="dialogTop:" + WindowFeature["top"] +"px;"; }
if(window.ModelessDialog ==null){window.ModelessDialog = new Object() ; };
if(name!="")
{
if(window.ModelessDialog[name]!=null && !window.ModelessDialog[name].closed )
{
window.ModelessDialog[name].focus();
return window.ModelessDialog[name];
}
}
var F = WindowFeature["left"] +WindowFeature["top"] + "dialogWidth:"+WindowFeature["width"] +"px;dialogHeight:"+WindowFeature["height"]+"px;center:1;help:0;resizable:" + WindowFeature["resizable"] +";status:No;scroll:no;unadorned:0;edge: raised;border:thick;"

if(isModal)
{
window.showModalDialog(url,self,F);
return false;
}
else
{
window.ModelessDialog[name] = window.showModelessDialog(url,self,F);
return window.ModelessDialog[name];
}
}
else
{
if(document.getBoxObjectFor)
{


if(isModal)
{
var Modal = window.open(url,name,"modal=1," + feature);
var ModalFocus = function()
{
if(!Modal.closed){Modal.focus();}
else{Modal =null;window.removeEventListener(ModalFocus,"focus");ModalFocus = null; };
}
window.addEventListener( "focus",ModalFocus, false );
return false;
}
else
{
return window.open(url,name,"modal=1," + feature);
}
}
else
{
return window.open(url,name,feature);
}
//
}
return null;
}

==== From opener Window =====
if (window.dialogArguments)
{
var openerV = window.dialogArguments;
} else {
var openerV = window.opener;
}

var getParentValue = openerV.metaData;


Download JS File

Encode / Decode to base64 - Javascript js

/*
* Title -> JavaScript Base64 Encoder Decoder
* Author -> Paul Gration
* URL -> http://www.i-labs.org
* Email -> pmgration(at)i-labs.org
*/

function JavaScriptBase64()
{
var string;
var base64;

this.JavaScriptBase64 = function(string)
{
this.string = new String(string);
this.base64 = new Array('A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3',
'4','5','6','7','8','9','*','/');
}

this.encode = function()
{
var binary = new String();
var result = new String();
for(i = 0; i < this.string.length; i++)
{
binary += String("00000000" + this.string.charCodeAt(i).toString(2)).substring(this.string.charCodeAt(i).toString(2).length);
}
for(i = 0; i < binary.length; i+=6)
{
var number = new Number();
var counter = new Number();
for(j = 0; j < binary.substring(i, i+6).length; j++)
{
for(k = 32; k >= 1; k-=(k/2))
{
if(binary.substring(i, i+6).charAt(counter++) == "1")
{
number += k;
}
}
}
result += this.base64[number];
}
return result;
}

this.decode = function()
{
var binary = new String();
var result = new String();
for(i = 0; i < this.string.length; i++)
{
for(j = 0; j < this.base64.length; j++)
{
if(this.string.charAt(i) == this.base64[j])
{
binary += String("000000" + j.toString(2)).substring(j.toString(2).length);
}
}
}
for(i = 0; i < binary.length; i+=8)
{
var number = new Number();
var counter = new Number();
for(j = 0; j < binary.substring(i, i+8).length; j++)
{
for(k = 128; k >= 1; k-=(k/2))
{
if(binary.substring(i, i+8).charAt(counter++) == "1")
{
number += k;
}
}
}
result += String.fromCharCode(number);
}
return result;
}
}
Download JS file

Encode / Decode to UTF 8 - Javascript js

===== Real Method Part ====
var changeValue = Utf8.encode(return_XML);

==== JS Part =====
var Utf8 = {

// public method for url encoding
encode : function (string) {
string = string.replace(/\r\n/g,"\n");
//var ss = string.toCharArray();
var utftext = "";

/*for (var i = 0; ss.length ;i++ )
{
utftext = ss[i];

if (utftext < 128) {
ss[i] = String.fromCharCode(ss[i]);
}
else if((ss[i] > 127) && (ss[i] < 2048)) {
ss[i] = String.fromCharCode((ss[i] >> 6) | 192);
ss[i] = String.fromCharCode((ss[i] & 63) | 128);
}
else {
ss[i] = String.fromCharCode((ss[i] >> 12) | 224);
ss[i] = String.fromCharCode(((ss[i] >> 6) & 63) | 128);
ss[i] = String.fromCharCode((ss[i] & 63) | 128);
}
}*/

for (var n = 0; n < string.length; n++) {

var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}

return utftext;
},

// public method for url decoding
decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;

while ( i < utftext.length ) {

c = utftext.charCodeAt(i);

if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}

}

return string;
}
}
Download js File

AJAX for workflow

This is introduction paper for how we can create Ajax component under XSLT UI enviroment.

Data is flowing as xml data.
In this case, the service from server side should return the data as XML format.

Download Presentation File

Download Ajax js component File

Remote Scanning Application for USB Connection

1 Introduction

For years technical integrators have struggled with installing different brands of scanners on a single network and letting users share those scanners in the same way that they share printers or MFP. People working at their own computers want to share any network scanner – scanning and importing directly into their own applications.
However, Samsung Electronics has the Network Scan software for supporting scanning work process under the network environments. But it does not support the connection of the scanner that is working with USB devices because Network Scan software did not implement with Twain interface. Therefore, it is required the Scanning software which is implemented with Twain interface and it also works web application so that user does not need to install application for scanning process because it can work with web browser.
1.1 Purpose
This document aim in specifying the “Remote Scanning Application for USB connection” developed for OJT Project in S/W 1 Lab. The document defines requirement specifications such as the project scope, purposes and the overall description. It also contains a user interface, functional, operational, other project issues that can be helpful in understanding the software requirement.

1.2 Scope

The title of this project is a Remote Scanning Application for USB connection that consists of three parts: the first part is a scanning management system which is for providing network web scan service to the user, the second part is user management system and the third part is folder management system.
This application supports Multi-User Connection System with Samsung MFP models of working class. The application is based on web environment that request web server and Database. But development of web server and Database for the application is out of this project. Therefore, the project is restricted only web application.


Download The File 1
Download The File 2
Download The File 3
Download The File 4
Download The File 5
Download The File 6
Download The File 7

My Simple UI Development Guide

-UI part is working with variable javascript components (js file : button, list and so on).

-Those components are gathered in container (UIManager component).

-Components are initialized and shown. All components are written in pure HTML/CSS/Javascript (method : getHTML).

-When the page (xsl file) is loading, all components and HTML representations are written into the page as HTML thus they are shown.

-DOM methods are used later. First components are generated as HTML (getHTML call).

-During page is loading this HTML is rendered and UIManager calls init method of each component (to bind JavaScript object and DOM objects)

-Also repaint method is used to adjust sizes and other stuff.

Download presition file

substring in xsl programming

* For loop from xsl files
<xsl:for-each select="/WSTResponse/Device">
<div id="detailDiv{@ID}">
ss
</div>
</xsl:for-each>

* Loop from style tag
<select name="Printer_name">
<xsl:for-each select="/WSTResponse/PluginInfo/WorkformParams/Param">
<option>
<xsl:attribute name="value">
<xsl:value-of select="value"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="value"/>
</xsl:attribute>
<xsl:variable name="printer"><xsl:value-of select="value"/></xsl:variable>
<xsl:value-of select="substring($printer, 0, 30)"/>
</option>
</xsl:for-each>
</select>

xsl programming : increase parameter

* For loop from xsl files
<xsl:for-each select="/WSTResponse/Device">
<div id="detailDiv{@ID}">
ss
</div>
</xsl:for-each>

* Loop from style tag
<xsl:variable name = "a" >75</xsl:variable>

<xsl:for-each select="/WSTResponse/Device">
<xsl:variable name="rr"><xsl:number/></xsl:variable>
<xsl:if test="$rr = 1">
#detailDiv<xsl:value-of select="@ID"/> { right: 400px; top:<xsl:number value="75"/>px ; POSITION: absolute; }
</xsl:if>
<xsl:if test="$rr > 1">
#detailDiv<xsl:value-of select="@ID"/> { right: 400px; top:<xsl:number value="($rr*37)+38"/>px ; POSITION: absolute; }
</xsl:if>
</xsl:for-each>

DOM method

* What is different between getElementById and getElementsByName
Is it simple array or complex array ?
Simple array > getElementById
Complex array > getElemetnByName

Example : Simple array > getElementById)
<input id="test" value=“ss">
var Obj = document.getElementById("test").value;
alert( Obj );// display “ss”

Example : complex array > getElementByName)
<input name="test" value=“11">
<input name="test" value=“22">
<input name="test" value=“33">
<script language="javascript">
var obj = document.getElementsByName("test");
alert( obj[0].value); // display “11”
</script>

* Disable text box : <input type=text disabled>

function f_check(){
if(document.form.checkbutton.checked==true){
document.form.textbox.disabled = true; //Or
//document.textbox.disabled = true;
} else if(document.form.checkbutton.checked==false){
document.form.textbox.disabled = false; //Or
//document.textbox.disabled = false;
}
}
</script>
<body>
<form name='form'>
<input type='text' name='textbox'>
<input type='checkbox' name='checkbutton' onclick='f_check()‘>
</form>
</body>

Like HashTable

*  hasttable - Input
var selectedUser_Array = [];
selectedUser_Array[key1] = value1;
selectedUser_Array[key2] = value2;

*  hasttable - Get
for (var key in selectedUser_Array) {
alert(“key : “+key+” value : “+ selectedUser_Array[key]);
}

*  hasttable - Delte
delete (selectUser_Array[key]);

Get check box number / value

======= What did the user check =========
<input type="checkbox" name="userListCheck" value=“1" onClick="buttonUpdate()">
<input type="checkbox" name="userListCheck" value=“2" onClick="buttonUpdate()">
………..
………..
--- Javascript ----
function buttonUpdate() {
var checkboxLength = document.getElementsByName("userListCheck").length;

for (var i = 0; i < checkboxLength ; i++ ) {
if (document.getElementsByName("userListCheck")[i].checked == true) {
//Do something when the check box is checked over one
//such as > UIManager.getInstance().getControl("RemoveButton").setEnabled(true);
break;
} else {
//Do something when the check box is not checked anything
//UIManager.getInstance().getControl("RemoveButton").setEnabled(false);
}
}
}

======= Get check value =========
---- HTML Part ----
<input type="checkbox" name="userListCheck" value=“1" onClick="buttonUpdate()">
<td width="270" class="Base1" id="userListName1" value=“1'">
<p>name</p></td>
<input type="checkbox" name="userListCheck" value=“2" onClick="buttonUpdate()">
<td width="270" class="Base1" id="userListName2" value=“2'">
<p>name</p></td>

………..

---- Javascript ----
function buttonUpdate() {
var checkboxLength = document.getElementsByName("userListCheck").length;

for (var i = 0; i < checkboxLength ; i++ ) {
if (document.getElementsByName("userListCheck")[i].checked != true) {
selectedValue = document.getElementsByName("userListCheck")[i].value;
selectedName = document.getElementById("userListName"+selectedValue).value;}
}
}
}

Check text number in Textarea field

function textCounter(field, countfield, maxlimit) {
if (field.value.length >= maxlimit) {
alert("Over your writting.");
if (field.value.length > maxlimit ) {
field.value = field.value.substring(0, maxlimit-1)   
}  
} else {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
}

Change image file by clicking 1

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="javascript">
function chgImg(){
var cur_img = document.nemo.src;
var get_filename = cur_img.substr(143); //split string
if (get_filename == "workform_top1.gif") {
document.nemo.src = "workform_top2.gif";
} else {
document.nemo.src = "workform_top1.gif";
}
}
</script>
</HEAD>
<BODY>
<img name="nemo" src="workform_top1.gif" onClick="javascript:chgImg();" width="560" height="22">
</BODY>
</HTML>

============ 2 =======================

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script language="javascript">
    var img = new Array("1.gif","2.gif");
    var i;   
i=0;

function chgImg() {
      document.nemo.src = img[i++];
     //document.images[0].src = img[i++];possible.
}
</script>
</HEAD>
<BODY>
     <img name="nemo" src="1.gif" onClick="javascript:chgImg();">
</BODY>
</HTML>

============= 3=====================
function showDetail(value) {
var get_param = "document."+"imgExtend" + value+ ".src";
//eval(‘document’+value).style.right = 400;
var get_img = eval(get_param);
var get_img_file = get_img.substr(72);
var get_id = "imgID"+value;
var ss = document.getElementById(get_id);

if (get_img_file == "libr_mainBar_ico2.gif" ) {
ss.src = "../../lib/rc/image/img/Workform_library/libr_mainBar_ico1.gif";
} else {
ss.src = "../../lib/rc/image/img/Workform_library/libr_mainBar_ico2.gif";
}
}

<a href="#" onclick="showDetail('{@ID}')">
<img name="imgExtend{@ID}" id="imgID{@ID}" src="../../lib/rc/image/img/Workform_library/libr_mainBar_ico2.gif" border="0" />
</a>