GPB download:

sudo apt-get install g++

tar xvfz protobuf-2.4.1.tar.gz



sudo make install

protoc use: 

protoc -I=$SRC_DIR --java_out=$DST_DIR $SRC_DIR/addressbook.proto

sudo apt-get install maven2

cd protobuf-2.4.1/java

mvn install

mvn package

add project :



'Programming > GPB' 카테고리의 다른 글

ubuntu java google protocol buffer install & example  (0) 2012.05.02
Posted by 한효정

sudo add-apt-repository ppa:sun-java-community-team/sun-java6

sudo apt-get update

sudo apt-get install sun-java6-bin sun-java6-jdk

sudo update-alternatives --config java

* another method

적당한 bin 파일 받음.

chmod 755 jdk-x.x.x.x.bin


ln -s /home/xxxx/jdk-x.x.x.x/ /usr/local/java

path 설정

vi .bashrc



export path =

Installing Oracle Sun Java (JDK) and setting JAVA_HOME in Ubuntu (Linux)

by Manish on May 6, 2012

This post is not only for people who are new to Linux or Java but also quick notes for me to setup my environment next time I install my system or setup a virtual machine.

Installing OpenJDK can be very simple but not Oracle JDK. You can use one of the two following commands (depending on which version you which to install) to setup OpenJDK in your linux environment.

sudo apt-get install openjdk-6-jdk
sudo apt-get install openjdk-7-jdk

But I have always used Oracle Sun JDK for my development. While Oracle JDK (earlier Sun JDK) is under the Binary Code License (earlier Sun License), OpenJDK is under GPL with a linking exception. From JDK version 7, Oracle has planned to support OpenJDK and withdraw the Operating System Distributor License for Java. This has resulted in a withdrawal of Oracle JDK from the repositories of Linux distributions. Therefore you can’t just use apt-get to install Oracle JDK.

Here is the stackoverflow link to help you choose between the Oracle JDK or OpenJDK.

But users who prefer to use the Oracle JDK binaries over OpenJDK builds packaged in their Linux distributions of choice can of course download the package from under the same terms as users on other platforms. Here is the direct link to JavaSE downloads.

Coming the point I have downloaded JDK 7 (update 4) for Linux x86 (32-bit) – file:jdk-7u4-linux-i586.tar.gz

Step 1: After downloading the file open the terminal and navigate to the file

tar -xf jdk-7u4-linux-i586.tar.gz

This will extract and create a jdk folder at your current path.

Step 2: Create a location to keep your new JDK . I prefer and usually use /usr/lib/jvm/

You may need root permission to create the /usr/lib/jvm (hence use sudo).

sudo mkdir /usr/lib/jvm 

Step 3: Move the extracted jdk folder to /usr/lib/jvm/

sudo mv jdk1.7.0_04 /usr/lib/jvm/

Step 4: Now we have to setup our system to use refer to our new jdk

sudo update-alternatives --install "/usr/bin/java" "java" \
"/usr/lib/jvm/jdk1.7.0_04/bin/java" 1

sudo update-alternatives --config java

And also register Firefox Java Plugin

sudo update-alternatives --install "/usr/lib/mozilla/plugins/" \
"" "/usr/lib/jvm/jdk1.7.0_04/jre/lib/i386/" 1

sudo update-alternatives --config

ALL DONE. You can test your java install by

java -version

Here is a small screen capture of what happened on my screen when I went through above steps

Oracle JDK Install

Finally if you need to add JAVA_HOME variable, you can do so by adding it to the.bashrc file in your home directory

Open .bashrc file using an editor. If you use VI then
vi ~/.bashrc

and add the following 2 lines in your .bashrc file.

export JAVA_HOME

There may be other ways to install, but this is what I have followed always.


'Programming > Java' 카테고리의 다른 글

sun java 설치  (0) 2012.05.01
Posted by 한효정

package org.springframework.samples.mvc.ajax.account;

import java.math.BigDecimal;
import java.util.Date;
import java.util.concurrent.atomic.AtomicLong;

import javax.validation.constraints.Future;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;

public class Account {

private Long id;

@Size(min = 1, max = 25)
private String name;

@NumberFormat(style = Style.CURRENCY)
private BigDecimal balance = new BigDecimal("1000");

@NumberFormat(style = Style.PERCENT)
private BigDecimal equityAllocation = new BigDecimal(".60");

@DateTimeFormat(style = "S-")
private Date renewalDate = new Date(new Date().getTime() + 31536000000L);

public Long getId() {
return id;

void setId(Long id) { = id;

public String getName() {
return name;

public void setName(String name) { = name;

public BigDecimal getBalance() {
return balance;

public void setBalance(BigDecimal balance) {
this.balance = balance;

public BigDecimal getEquityAllocation() {
return equityAllocation;

public void setEquityAllocation(BigDecimal equityAllocation) {
this.equityAllocation = equityAllocation;

public Date getRenewalDate() {
return renewalDate;

public void setRenewalDate(Date renewalDate) {
this.renewalDate = renewalDate;

Long assignId() { = idSequence.incrementAndGet();
return id;

private static final AtomicLong idSequence = new AtomicLong();

public String toString() {
return new ToStringCreator(this).append("id", id).append("name", name)
.append("balance", balance).append("equityAllocation",
equityAllocation).append("renewalDate", renewalDate)


package org.springframework.samples.mvc.basic.account;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

public class AccountController {

private Map<Long, Account> accounts = new ConcurrentHashMap<Long, Account>();
public String getCreateForm(Model model) {
model.addAttribute(new Account());
return "account/createForm";
public String create(@Valid Account account, BindingResult result) {
if (result.hasErrors()) {
return "account/createForm";
this.accounts.put(account.assignId(), account);
return "redirect:/account/" + account.getId();
@RequestMapping(value="{id}", method=RequestMethod.GET)
public String getView(@PathVariable Long id, Model model) {
Account account = this.accounts.get(id);
if (account == null) {
throw new ResourceNotFoundException(id);
return "account/view";


package org.springframework.samples.mvc.basic.account;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

public class ResourceNotFoundException extends RuntimeException {
private Long resourceId;
public ResourceNotFoundException(Long resourceId) {
this.resourceId = resourceId;
public Long getResourceId() {
return resourceId;

'Programming > Spring' 카테고리의 다른 글

스프링 참고할만한 소스들....  (0) 2011.12.11
스프링 MVC 예제 링크 및 간단 정리..  (0) 2011.11.19
Posted by 한효정

'Programming > Install&Tip' 카테고리의 다른 글

우분투에 opencv 2.2 설치하기  (0) 2011.10.08
sqlyog 무료버전  (0) 2011.09.05
[펌] 티스토리에 소스 코드 올리기 - Google SyntaxHighlihter  (0) 2010.06.09
linux install tip  (0) 2010.06.07
tar & gz & bz2 사용법  (0) 2009.05.31
Posted by 한효정

'Programming > Install&Tip' 카테고리의 다른 글

우분투에 opencv 2.2 설치하기  (0) 2011.10.08
sqlyog 무료버전  (0) 2011.09.05
[펌] 티스토리에 소스 코드 올리기 - Google SyntaxHighlihter  (0) 2010.06.09
linux install tip  (0) 2010.06.07
tar & gz & bz2 사용법  (0) 2009.05.31
Posted by 한효정

티스토리에서 프로그래밍 언어를 효과적으로 보여주기 위해서는 어떻게 해야할까?
   곳곳에서 깔끔한 뷰어를 보고 놀라서 어떻게 해야할지 궁금해하다 찾아보았다. 
   몇 몇의 블로그에서 소개하고 있었는데, 그 중 핵심적인 내용을 뽑아 올리겠다. 

SyntaxHighlighter 2.0.287 번을 사용하면 손쉽게 만들 수 있다. 

 우선 이 파일을 받고 압축을 풀면 세 개의 폴더가 나오는데, 그 중에서 
scripts와 style 풀더에 있는 내용을 티스토리의 스킨의 HTML/CSS편집의 파일 올리기를 통해 모두 올린다.! 그런 다음에 HTML/CSS편집에서 skin.html에 보면 위쪽에서 대여섯번째 줄에  title head을 찾을 수 있는데 , 그 중간에 다음의 코드를 복사해서 넣는다.
01.<script src="./images/shCore.js"type="text/javascript"></script>
02.<script src="./images/shBrushBash.js"type="text/javascript"></script>
03.<script src="./images/shBrushCpp.js"type="text/javascript"></script>
04.<script src="./images/shBrushCSharp.js"type="text/javascript"></script>
05.<script src="./images/shBrushCss.js"type="text/javascript"></script>
06.<script src="./images/shBrushDelphi.js"type="text/javascript"></script>
07.<script src="./images/shBrushDiff.js"type="text/javascript"></script>
08.<script src="./images/shBrushGroovy.js"type="text/javascript"></script>
09.<script src="./images/shBrushJava.js"type="text/javascript"></script>
10.<script src="./images/shBrushJScript.js"type="text/javascript"></script>
11.<script src="./images/shBrushPhp.js"type="text/javascript"></script>
12.<script src="./images/shBrushPlain.js"type="text/javascript"></script>
13.<script src="./images/shBrushPython.js"type="text/javascript"></script>
14.<script src="./images/shBrushRuby.js"type="text/javascript"></script>
15.<script src="./images/shBrushScala.js"type="text/javascript"></script>
16.<script src="./images/shBrushSql.js"type="text/javascript"></script>
17.<script src="./images/shBrushVb.js"type="text/javascript"></script>
18.<script src="./images/shBrushXml.js"type="text/javascript"></script>
19.<link href="./images/shCore.css" type="text/css"rel="stylesheet"><link href="./images/shThemeDefault.css"type="text/css" rel="stylesheet">
20.<script type="text/javascript"> SyntaxHighlighter.config.clipboardSwf = './images/clipboard.swf'; SyntaxHighlighter.all();</script>
이렇게 하면 기본적인 세팅은 모두 끝난 상태가 된다.!
이제 사용하는 것만 남았다. 글쓰기를 하면 EDIT가 보이는데, 이를 클릭하면 HTML코드로 입력할 수 있다. 여기서 아래와 같이 입력하고 소스 코드를 복사해 넣으면 깔끔한 소스코드를 볼 수 있다.!!
1.<pre class="brush: cpp">
2.// 코드를 적는다
아래는 각 언어별 명칭을 나타낸 표이다. 
"brush:명칭"을 쓰면 각 언어별로 표현가능하다.!

Brush nameBrush aliasesFile name
Bash/shell bash, shell shBrushBash.js
C# c-sharp, csharp shBrushCSharp.js
C++ cpp, c shBrushCpp.js
CSS css shBrushCss.js
Delphi delphi, pas, pascal shBrushDelphi.js
Diff diff, patch shBrushDiff.js
Groovy groovy shBrushGroovy.js
JavaScript js, jscript, javascript shBrushJScript.js
Java java shBrushJava.js
PHP php shBrushPhp.js
Plain Text plain, text shBrushPlain.js
Python py, python shBrushPython.js
Ruby rails, ror, ruby shBrushRuby.js
SQL sql shBrushSql.js
Visual Basic vb, vbnet shBrushVb.js
XML xml, xhtml, xslt, html, xhtml shBrushXml.js

Reference :

'Programming > Install&Tip' 카테고리의 다른 글

우분투에 opencv 2.2 설치하기  (0) 2011.10.08
sqlyog 무료버전  (0) 2011.09.05
[펌] 티스토리에 소스 코드 올리기 - Google SyntaxHighlihter  (0) 2010.06.09
linux install tip  (0) 2010.06.07
tar & gz & bz2 사용법  (0) 2009.05.31
Posted by 한효정

21살에 짠 코드는 벌써 8년 전... 헉스; 지금 봐도 아주 나뻐 보이지는 않는다.

#ifndef MYSTRING_H
#define MYSTRING_H

char *my_strcat( char *src, const char *tail )
    char *s = src;
    for( ; *src ; src++ );
    for( ; *tail ; src++, tail++ )
        *src = *tail;
    *src = '\0';
    return s;

char* my_strchr(char *src, int c)
	int end=1;
		if(*src == c) 
			end = 0;
	if(end == 1) return NULL;
	else return src;

int my_strcmp(const char *s1, const char *s2)
	int result;
	for(; *s1!='\0' || *s2!='\0' ; s1++,s2++)
		result = *s1 - *s2;
		if(result != 0) return result; 
	return 0;

char *my_strcpy( char *dest, const char *src )
    char *s = dest;
    for( ; *src ; dest++, src++ )
        *dest = *src;
    *dest = '\0';
    return s;

int my_strlen( const char *s1 )
    int i = 0;
    for( i = 0 ; *s1 ; i++, s1++ );
    return i;

char* my_strlwr(char *s) 
		if( (*s > 64) && (*s < 91) ) *s = *s + 32;
		return s;

char* my_strupr(char *s) 
		if( (*s > 96) && (*s < 123) ) *s = *s - 32;
		return s;

char* my_strset(char *s,int ch) 
        *s = ch;
	return s;

char* my_strrev(char *s) 
	char temp;
	char* s_temp = s;
	for(;s_temp > s;s++,s_temp--)
        temp = *s_temp;
		*s_temp = *s;
		*s = temp;
	return s;

char* my_strstr(char *s1, char *s2) 
	char *s1_temp, *s2_temp;
		s1_temp = s1;
        s2_temp = s2;
		if(*s1_temp == *s2_temp)
				if(!*s2_temp) return s1;
				if(*s1_temp != *s2_temp) break;
				if(!*s1_temp) break;
	return NULL;


'Programming > C/C++' 카테고리의 다른 글

내가 만든 문자열 관련 함수  (0) 2010.06.09
Posted by 한효정
이전버튼 1 2 3 이전버튼

블로그 이미지
착하게 살자.





 « |  » 2019.6
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

최근에 달린 댓글

글 보관함