快速入門ice--使用eclipse開發ice

來源:互聯網
上載者:User

Zeroc ICE Quick Start 1             環境搭建

1.1            1.1          運行環境配置 1.2          下載

本例下載的版本是Ice-3.5.1-6.msi

https://zeroc.com/download/Ice/3.5/Ice-3.5.1-6.msi

  1.3          安裝ICE運行環境

建議安裝在根目錄,如果不安裝在根目錄,也建議不要裝在有空格的目錄

本例安裝目錄為C:\ZeroC\Ice-3.5.1,安裝同時會產生一個Ice-3.5.1-demos目錄,這裡面有很多demo,本例的安裝位置為C:\ZeroC\Ice-3.5.1-demos

配置環境變數

ICE_HOME= C:\ZeroC\Ice-3.5.1

Path= %ICE_HOME%\bin;

CLASSPATH=%ICE_HOME%\lib\ice.jar;%ICE_HOME%\lib\db.jar;%ICE_HOME%\lib\Freeze.jar;%ICE_HOME%\lib\IceBox.jar;

檢查安裝是否成功

在cmd視窗執行 slice2cpp –v

如上顯示即表示安裝成功

  1.4          安裝ICE 開發外掛程式

本例使用的eclipse版本為4.5,jdk版本為1.8.0_60

開啟eclipse,選擇help->Eclipse Marketplace

輸入zeroc ice 顯示如下

 

點擊Install,選擇Ice Builder for Eclipse 4.0.0 並安裝

安裝完後eclipse會重啟,重點後,點擊Windows->Preferemces.配置ICE運行環境

選擇ICE的安裝目錄即可

  2             開啟ICE之旅 1.1          編寫ICE Server端

建立一個Java Project

為項目添加ICE屬性

這時會產生兩個目錄,如下

在slice目錄建立一個ice描述檔案

a).HelloWord.ice

代碼如下:

module com

{

       modulemyice

       {

              moduletest

              {

                     interfaceHelloWorld

                     {

                            stringsayHello(string s);

                     };

              };

       };

};

 

b).編寫servant

HelloWordldI.java

package com.myice.servant;

import com.myice.test._HelloWorldDisp;

import Ice.Current;

public classHelloWordldI extends _HelloWorldDisp{

    @Override

    public StringprintString(String s,Current __current){

       

        System.out.println("client message:"+s);

        return "Hello World:"+s;

    }

}

 

c).使用代碼方式發布servant,編寫Server

IceServer.java

package com.myice.server;

import com.myice.servant.HelloWordldI;

public classIceServer extends Ice.Application{

    public static void main(String[] a) {

        IceServer app = new IceServer();

        String[]args={"",""};

       

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.