ステップ1:
に進みE:\weblogic81\user_projects\domains\mydomain
ます。次に、Setenv
コマンドを入力します。次のように
E:\weblogic81\user_projects\domains\mydomain>setenv
ステップ2:
Weblogic.jar
ファイルは、クライアント アプリケーションで必要です。次のパスに含まれる場合がありますE:\weblogic81\weblogic81\server\lib\weblogic.jar
。したがって、このフォルダのクラスパスを設定するか、この weblogic.jar ファイルをアプリケーション フォルダにコピーして、最初にアプリケーションで weblogic.jar ファイルを使用できるようにします。
E:\weblogic81\user_projects\domains\mydomain>set CLASSPATH=%CLASSPATH%;E:\weblogic81\weblogic81\server\lib;.
ステップ 3:
上記のようにコマンド プロンプトでドメイン フォルダーに移動し、クラスパスを設定します。他のクラスパスを邪魔しないようにするには、クラスパスを次のように設定します。
set CLASSPATH=%CLASSPATH%;E:\weblogic81\weblogic81\server\lib;.
ここで ( .
) ドットは、クラスパスを現在のディレクトリに設定することを表します。
ステップ 4:
クラスパスを設定したら、コマンド STARTWEBLOGIC を次のように実行します。
E:\weblogic81\user_projects\domains\mydomain>STARTWEBLOGIC
ステップ 5:
weblogic サーバーにログインしないでください。すでにログインしている場合は、ログアウトして、myeclipse またはその他の IDE で次のコードを記述します。
ステップ 6:
package directory.service;
import java.util.*;
import weblogic.jndi.*;
import java.io.FileInputStream;
import javax.naming.*;
public class GetInitContext {
/**
* @param args
*/
public static void main(String[] args) {
try{
weblogic.jndi.Environment env=new weblogic.jndi.Environment();
weblogic.jndi.Environment environment = new weblogic.jndi.Environment();
environment.setInitialContextFactory(
weblogic.jndi.Environment.DEFAULT_INITIAL_CONTEXT_FACTORY);
env.setProviderUrl("t3://localhost:7001");
env.setSecurityPrincipal("agni");
env.setSecurityCredentials("agnidevam");
Context context=env.getInitialContext();
System.out.println("got the initial context for weblogic server---> "+context);
context.createSubcontext("sone");
context.bind("agni one",new Integer(10));
context.createSubcontext("sone/sctwo");
context.bind("agni two",new Integer(20));
context.createSubcontext("sone/sctwo/scthree");
context.bind("agni three",new Integer(30));
System.out.println("subcontex object created please check in admin server for more details");
}
catch(Exception e){
System.out.println("file inputstream exception ---> "+e);
}
}
}
ステップ 7:
上記のコードを実行し、weblogic にログインして右クリックするmyserver>view jndi tree>
と、バインドされたオブジェクトの情報が表示されます。