Bluemix Watson 을 사용하기 위한 이클립스 설정
아래에 설명하는 내용은 IBM Developworks에 소개된 내용입니다.
원래는 영문으로 되어 있는 내용이며, 아래 추가한 블로그에서는 이 내용을 한글로 다시 바꿔서 좀더 쉽게 설명하고 있습니다.
요즘 관심을 갖고 있고, 이것저것 건들어 보는 것 중에 하나가 Watson 이라 이 내용을 공유합니다.
출처 :
https://www.ibm.com/developerworks/library/cc-translation-app-eclipse-watson-bluemix-trs/index.html
출처 2(한글): http://sesamy.tistory.com/9
아래의 설명대로 하기위해서는 bluemix 계정과 이클립스등의 기본 준비사항이 필요합니다.
이에
Part1에서는 이클립스에서 블루믹스서버 연결과 로컬서버 설치하는 튜톨리얼이다.
1. 이클립스 설치하기
이클립스다운로드 페이지클릭
Eclipse IDE for Java EE Developers Neon버전설치할것
2. 프로젝트생성하기
File -> New -> Dynamic Web project설정->프로젝트이름 입력(SampleWebApp)
3. Bluemix서버만들기
서버탭을 눌러서 아래와 같이보이면 서버설치를 해야한다.
메뉴->New->Other->Server->Server ->IBM Bluemix
블루믹스 아이디와 패스워드를 입력한다.아래 Validte Account클릭 -> Finish클릭
다음과같이 Bluemix서버가 연결된 것을 확인할 수 있다.
4. 로컬호스트서버 만들기
메뉴->New->Other->Server-> IBM -> WebSphere Application Server Liberty
서버c:\\WASServer 입력, Was Liberty Runtime->next
5. 샘플HTML프로그램 생성하기
그림과 같이 Perspective아이콘을 클릭하여 web Perspective을 선택하여 web개발에 최적화시킨다.
File->New->HTML file -> default상태로 생성한다.
다음의 코드를 index.html파일에 옮겨입력한다.
<!DOCTYPE html>
<
html
>
<
head
>
<
title
>The IBM Bluemix Translation Application</
title
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
>
<
link
rel
=
"stylesheet"
href
=
"theme/myStyle.css"
/>
</
head
>
<
body
>
<
table
>
<
tr
>
<
td
colspan
=
"2"
>
<
img
class
=
"eclipseIcon"
src
=
'images/WorldIcon.png'
>
</
td
>
<
td
>
<
h4
> John J Andersen <
span
class
=
"blue"
>Translation Application</
span
>. </
h4
>
</
td
>
</
tr
>
<
tr
>
<!-- The message comes from /TranslationServlet -->
<
td
colspan
=
"4"
>
message
</
td
>
</
tr
>
<
tr
>
<
th
colspan
=
"2"
>Enter text to be translated</
th
>
<
th
colspan
=
"2"
>Translated text</
th
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
>
<
form
action
=
"SimpleServlet"
>
<
textarea
rows
=
12
cols
=
50
autofocus
name
=
"inputText"
></
textarea
><
br
>
<
input
type
=
"radio"
name
=
"target"
value
=
"French"
> French <
br
>
<
input
type
=
"radio"
name
=
"target"
value
=
"Spanish"
checked> Spanish <
br
>
<
input
type
=
"radio"
name
=
"target"
value
=
"English"
> English <
br
>
<
input
type
=
"submit"
name
=
"translate"
Value
=
"Translate"
>
<
input
type
=
"submit"
name
=
"speech"
Value
=
"Speech2Text"
>
</
form
>
</
td
>
<
td
colspan
=
"2"
style
=
'vertical-align:top;'
>
<
textarea
id
=
"outPut"
rows
=
"12"
cols
=
"50"
readonly
name
=
"translatedText"
></
textarea
>
</
td
>
</
tr
>
<
tr
>
<!-- This string will identify the language of the input text - it comes from /TranslateServlet -->
<
td
style
=
'vertical-align:bottom;'
>
<
h1
id
=
'inputLanguage'
></
h1
>
</
td
>
</
tr
>
</
table
>
</
body
>
</
html
>
File->New->Folder->WebContent->images 폴더를 생성함
이폴더에 필요한 이미지파일을 넣어줌
6. 어플리케이션 서블릿 생성
File->New->other -> servlet -> next
다음의 항목을 입력한다.
다음의 파일을 복사하여 붙여넣는다.
package jja.sample.servlet; import java.io.IOException; import javax.servlet.*; import javax.servlet.annotation.WebServlet; import javax.servlet.http.*; /** * Servlet implementation class SimpleServlet */ @WebServlet("/SimpleServlet") public class SimpleServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.getWriter().print("Hello World! from " + request.getServerName()); } }
붙여넣기를 하면 에러가 생기는것을 볼수있다.
Project -> Properties ->Targeted Runtimes를 설정해줘야한다.
4. 로컬서버로 테스트해보기
Run as-> Run on Server
다음과같이 로컬서버로 연결된것을 볼수있다.
'IT&컴퓨터 > IT 인터넷' 카테고리의 다른 글
가상화폐 전망 - 중국의 규제 (0) | 2018.01.09 |
---|---|
텔레그램 - 가상화폐 도입 (0) | 2018.01.09 |
암호화 - RSA 암호화 알고리즘 (0) | 2018.01.08 |
보안 - 랜섬웨어 복구 (0) | 2018.01.08 |
유용한 크롬 플러그인 - 마우스 해제, 광고 차단 (0) | 2018.01.08 |