🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14982

Re: Class.class <> Object.getClass() <> AClass.class

#14982
From: Hugo Ferreira
Date: Thu, 22 Jul 1999 00:00
77 lines
2889 bytes
Christophe

Yep,
Here is the sample code from ObjectSpace.com for its Voyager ORB. It
compiles
and runs ok.

////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////
// copyright 1997-1999 objectspace

package RemoteInterface.Implemented;

import com.objectspace.voyager.*;

public class Naming2
  {
  public static void main( String[] args )
    {
    try
      {
      Voyager.startup();
      // create a remote stockmarket
      System.out.println("create a remote stockmarket");
      String marketClass = Stockmarket.class.getName();
      String marketName = "//localhost:8000/NASDAQ";
      IStockmarket market1 = (IStockmarket) Factory.create( marketClass,
"//localhost:8000" );

      // bind the stockmarket to the symbol "NASDAQ"
      System.out.println("bind the stockmarket to the symbol 'NASDAQ'");
      Namespace.bind( marketName, market1 );

      // lookup the stockmarket
      System.out.println("lookup the stockmarket");
      IStockmarket market2 = (IStockmarket) Namespace.lookup( marketName );
      System.out.println( marketName + " -> " + market2 );

      // unbind the symbol
      System.out.println("unbind the symbol");
      Namespace.unbind( marketName );
      // lookup the stockmarket again
      System.out.println("lookup the stockmarket again");
      IStockmarket market3 = (IStockmarket) Namespace.lookup( marketName );
      System.out.println( marketName + " -> " + market3 );
      }
    catch( Exception exception )
      {
      System.err.println( exception );
      }

    Voyager.shutdown();
    }
  }

////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////

Christophe wrote in message <7n6m5b$lsh13@forums.borland.com>...
>Hi
>
>a) I haven't found info about this field in JDK 1.2 help and I can't
compile
>such code :
>    Object myObject=new Object();
>    String name = myObject.class.getName();
>Are you sure it works ?
>
>b) If you know the class name you can use Class.forName(String className) :
>which return a class object.
>Example : if you want to get an applet class object use :
>  Class cls=Class.forName("java.applet.Applet");
>
>Hope this help.
>
>
>
Technical Details
Message-ID: <7n6r7r$lsb13@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7n6g9c$ls06@forums.borland.com> <7n6m5b$lsh13@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,3aab8f0f399fbb90
X-Google-Attributes: gidf74b3,public
From: "Hugo Ferreira" <HugoF@cocaina.inescn.pt>
Subject: Re: Class.class <> Object.getClass() <> AClass.class
Date: 1999/07/22
Message-ID: <7n6r7r$lsb13@forums.borland.com>
X-Deja-AN: 503956471
References: <7n6g9c$ls06@forums.borland.com> <7n6m5b$lsh13@forums.borland.com>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700
Newsgroups: borland.public.jbuilder.java.language