How to Run Simple JNDI Program

This is the Simple JNDI Lookup.java Program which is provided in sun website...
Program compiles Successfully...
While running i got the error...
java Lookup (What name should i give here)
Appart from this i have one binding file(.bindings)
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;
import javax.naming.directory.InitialDirContext;
class Lookup {
public static void main(String[] args) {
     // Check that user has supplied name of file to lookup
     if (args.length != 1) {
     System.err.println("usage: java Lookup <filename>");
     System.exit(-1);
     String name = args[0];
     // Identify service provider to use
     Hashtable env = new Hashtable(11);
     env.put(Context.INITIAL_CONTEXT_FACTORY,
     "com.sun.jndi.fscontext.RefFSContextFactory");
     try {
     // Create the initial context
     Context ctx ;
     Lookup lu=new Lookup();
     Thread.currentThread().setContextClassLoader(lu.getClass().getClassLoader());
     ctx = new InitialDirContext(env);
     // Look up an object
     Object obj = ctx.lookup(name);
     // Print it out
     System.out.println(name + " is bound to: " + obj);
     // Close the context when we're done
     ctx.close();
     } catch (NamingException e) {
     System.err.println("Problem looking up " + name + ": " + e);
}

first,u should add fscontext.jar and providerutil.jar in your classpath,when run:java Lookup ,must add arguement like: c:\ or c:\jndi(jndi must be created)
document:
The following JNDI environment properties are relevant to the file system service provider. See the JNDI documentation for a description of how properties are initialized using the environment properties, system properties, applet parameters, and resource files.
java.naming.factory.initial
This environment property is used to select the file system service provider. It's not actually used by the provider itself. It specifies the class name of the initial context factory for the provider. It can have one of two values. The first choice names the class responsible for file system access.
For example:
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.FSContextFactory");
The second choice names the class--a subclass of FSContextFactory--which adds the ability to lookup and store Java objects in the file system.
For example:
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
This environment property must be set if you are using the file system provider for the initial context. The only exception is if you supply only URLs to the initial context, in which case, you don't need to specify this property. See the Types of Objects and how Objects are Named section for details.
java.naming.provider.url
Specifies the file to be used as the root context. It must be a file URL representing a directory in the file system.
For example:
file:///home/kafka
this URL will cause the provider to use the directory named kafka in the directory home in the root directory as the base context. Performing a list() on the initial context would be equivalent to typing the UNIX command ls in the directory /home/kafka directory. If this property is not set, it defaults to the root of the local file system.
java.naming.factory.state
A colon-separated list of the fully qualified class names of state factory classes used to get an object's state for storing given the object itself. You can use this mechanism to transform an object into forms that the files system service provider supports. The file system service provider supports storing Reference and Referenceable objects. See javax.naming.spi.NamingManager.getStateToBind() for details.
java.naming.factory.object
A colon-separated list of the fully qualified class names of object factory classes for transforming objects read from the file system. You can use this mechanism to transform an object into forms expected by the application. See javax.naming.spi.NamingManager.getObjectInstance() for details.
Types of Objects and how Objects are Named
.............

Similar Messages

  • How to run a Concurrent Program from the back end?

    Hi,
    How to run a Concurrent Program from the back end?
    Is it Possible to see that Concuurent Request id which we run from the back end, in the front end?
    If yes, then Please Give reply how to write the code
    Thanks in Advance,
    Bharathi.S

    This is documented in Chapter 20 of the Application Developers Guide http://download.oracle.com/docs/cd/B53825_03/current/acrobat/121devg.pdf. These MOS Docs also have some information available
    221542.1 - Sample Code for FND_SUBMIT and FND_REQUEST API's
    235359.1 - How to Launch Planning Data Pull MSCPDP using FND_REQUEST.SUBMIT_REQUEST
    HTH
    Srini

  • How to run automatic payment program business area wise

    dear all
    please let me know how to run automtic payment program business area wise.
    for example business area 2020 we want to make payment business area wise.
    what are the back gorund settings for congigration Tc- fbzp
    wht are the configrations forTC- f110
    regards
    babu

    Hi,
    You can make payments business area wise if you had ticked payment goup business area wise in the payment method in company code screen. However you will have to give company codes in the payment parametets, but payments will be grouped by business area.
    Thanks,
    Ramesh.

  • How to run a ABAP Program in Batch JOB

    How to run a ABAP Program in Batch JOB ?

    Hello Manish,
    Using transaction SM36 you can define the batch job along with the start conditions for that job.
    1. Transaction SM36.
    2. Give the Z name of the job in the 'Job Name' input field.
    3. Click on 'Steps' button from the application toolbar.
    4. On the 'Create Step 1' dialog box, give the name of the ABAP program in the 'ABAP Program' section' along with the variant.
    5. Click on 'Check Input' button from the dialog box.
    6. Click on 'Save' button from the dialog box once the check is successful.
    7. One list will be shown. Click on Back button from the standard toolbar.
    8. Click on 'Start Conditions' button from the application toolbar. Specify the start condition e.g. immediate. Click on save.
    9. The job staus is now scheduled.
    10.Click on Save button from the standard toolbar of SM36. The job status will be released.
    Using SM37 you can monitor the status of the job.
    This will sort out your problem.
    PS If the answer solves your query, plz reward points.
    Regards

  • How to run a java program in another folder

    Hello!
    I want to run for example the java class file in the path ./sourcecode/javafile.class. It works fine if I do the following:
    cd sourcecode
    java javafile
    but it cannot work if I do:
    java sourcecode/java
    The error it outputs is NoClassDefFoundError.
    Can someone tell me how to run a java program in another folder
    thanks a lot.

    You need to specify the classpath using the -cp flag when running. so instead of
    "java sourcecode/javafile"
    Try
    "java -cp sourcecode javafile"

  • How to run the Servlet program?

    hi, all, I am new to servlet, and I want to know how to run the servlet program. I got the TomCat and Java JDK install in my computer, something else I need for create and run the servlet program?

    no that is all u need to run servlets. u can try few of the servlets that come with tomcat

  • How to run the package programs in eclipse ?

    hi all,
    how to run the package programs in eclipse ?
    plz clarify...
    regards
    balakrishna.m

    package source code is
    package package1;
    public class ClassaA
              public void displayA()
                   System.out.println("class A");
         }java source code is import package1.ClassA;
         class Packagetest1
              public static void main(String args[])
                   ClassA objectA = new ClassA();
                   objectA.displayA();
         }if i write the notepad means its executing successfully..
    but in eclips is not working..
    plz help me..

  • How to run windows application programs in mac book pro, how to run windows application programs in mac book pro

    how to run windows application programs in mac book pro, how to run windows application programs in mac book pro

    Install Windows..either by Boot Camp or via virtual machine from VMWare, Parallels or Virtual Box

  • How to run the client program in weblogic 8.1 server

    Hi
    I am new to EJB 2.0. I am deployed sucessfully a session ejb program.
    While running an ejb client program it throws an exception. In my session ejb program i created two jar file. one is sessionejb.jar and another one is sessionejbclient.jar. In sessionejb.jar contains home ,remote ,session bean class and deployment descriptor.In sessionejbclient.jar contains home,remote and client program. Both jar files are included in class path of environment variable( i am using Standalone server).
    Plese guide me how to run an session ejb client correctly.
    Regards
    Jaiganesh

    Both jar files are
    included in class path of environment variable( i am
    using Standalone server).did u include both these jars in the "weblogic's class path" ?
    in that case, it obviously wont work.
    what u need is an understanding of the following topics (i have described them briefly, but for details u can always check the documentation of weblogic):
    1. Class loaders in weblogic: there are various levels of class loaders. at the top is the weblogic's class loader. below it are various EARs' class-loaders. and so on....
    2. Packaging. You must ensure that in the same class loader, there are not two classes from 2 different jars.
    hope that helps

  • URGENT: How to run a Java program from a different directory?

    Hi.
    How do I run a Java program from a directory that the file is not located in? So lets say im in c:\Java. But the file is in c:\Java\abc\efg\.
    What would be the command to run the Java file from c:\Java.
    I can't remember it and I need it asap.
    Cheers.

    If the class you are trying to run is MyApp.class, try
    c:\Java\>java -cp abc\efg MyAppThe actual classpath you specify will depend on whether or not MyApp.class is in a package (I've assumed it isn't) and whether or not any 3rd party jars are involbed (I've assumed not).
    Edited by: pbrockway2 on Apr 1, 2008 6:42 PM
    The command arguments read as "Run the MyApp class using as a classpath abc\efg relative to here (c:\Java)".

  • How to run a java program without Java Compiler

    I have a small project and I want share it with my friends but my friend'pc have not
    Java compiler.
    for example, I writen a application like YM, then 2cp can sent,receive messege. My cumputer run as Server, and my frien PC run as client.
    How can my friend run it? or how to create an icon in dektop tu run a java program..??..
    (sorry about my English but U still understand what i mean (:-:)) )

    To run a program you don't need a Java compiler. Just the Java Runtime Engine. That can be downloaded from the Sun website and comes with an installer.
    You could then turn your application into an executable jar file and start it somehow like jar myYM.
    There is also software that packs a Java program into an executable file. I've never used that but one that comes to my mind is JexePack. It's for free if you can live with a copyright message popping up every time you start the program.
    http://www.duckware.com/jexepack/index.html

  • How to run a spool program in unix environment within a shell script

    Hi
    I have written a spool program , which i run from SQL * PLUS
    using
    @'path of the spool file having extension .sql'
    Now i want to include this spool program within the shell script , please help me , how to do it.
    Thanks in advance ..

    user8703472 wrote:
    Thank You Sir for the reply .
    #!/bin/ksh
    ORACLE_SID=<SID>; export ORACLE_SID
    ORACLE_HOME=<ORACLE_HOME>; export ORACLE_HOME
    $sqlplus / as sysdba <<-EOFSQL1 >> output.log 2>&1
    spool /tmp/a.log
    select * from v\$instance
    spool off;
    EOFSQL1
    Please explain me this statement $sqlplus / as sysdba
    and also what a.log contains .
    i have the user id and password for the DB.
    should i write something like this
    $sqlplus -Uusername -Ppassword -Sservername
    i know how to run a procedure from isql(sybase DB)
    Ahh.... but oracle is not just sybase under a different name.
    It would be a good investment in your career to go to tahiti.oracle.com. Drill down to your product and version. There you will find the complete doc library.
    You should spend a few minutes just getting familiar with what kind of documentation is available there by simply browsing the titles under the "Books" tab.
    Open the Reference Manual and spend a few minutes looking through the table of contents to get familiar with what kind of information is available there. Learning where to look things up in the documentation is time well spent on your career.
    For your immediate task, spend a few minutes looking through the SQLPlus User Guide and Reference.
    Then set yourself a plan to dig deeper.
    - Read a chapter a day from the Concepts Manual.
    - Look in your alert log and find all the non-default initialization parms listed at instance startup. Then read up on each one of them in the Reference Manual. Take a look at your listener.ora, tnsnames.ora, and sqlnet.ora files, then bounce what you see there in the network administrators manual.
    Give a man a fish and he eats for a day. Teach a man to fish and he eats for a lifetime.
    But this project , i need to run the spool program from with in a shell script .We see what you mean, but the term "spool program" has no meaning in Oracle and only serves to cloud the issue. I know you are used to using this term with other products, but "When in Rome ...."
    >
    Thank You in advance ..

  • Can I write and run simple java programs in Xcode

    I need to write and run basic java programs on my mac. I would like to run it in Xcode, but I don't know how to set it up? Is there a way?

    Read the following discussion from last month on here:
    Can Xcode 4.5.1 compile/run java?

  • How to run a labview program(*.vi) in VB6?

    Hi:
    I use measurement studio 6 and VB6.I want to run a labview program(*.vi) which is no parameters to input to judge whether spectrum ananlyzer is in ready state.How can I run the program? Can the judgement be implemented through measurement studio 6?
    Thanks for your help!

    You can do this with VI Server. Here are a few articles and examples that you can look at to get started:
    LabVIEW and Visual Basic - Example 3: Sharing Code with Visual Basic
    Calling a LabVIEW Executable from Visual Basic
    Calling a LabVIEW VI from Visual Basic through ActiveX
    Passing Data between LabVIEW and Visual Basic Using the ActiveX Server
    Calling LabVIEW as an ActiveX Server from Visual Basic
    - Elton

  • How to run a client program in Session bean using weblogic 8.1

    Hi
    I am new to weblogic server 8.1. I sucessfully deployed session ejb Session Bean. I created sessionbean jar file and put it it classpath also.
    and also i created sessiobeanclient jar file, it included in class path.
    While running client program it throws exception like noclass def found exception
    plz tell me the right way to run the session ejb program.
    bye

    Hi,
    You have to follow the given steps before you are going to run the client program that invokes the session bean .
    1)set the Weblogic Environment using the tool setWLSEnv
    2)place the Session bean jar file in classpath
    3)run the client program
    Note:If the client has to execute on remote machine we need to copy client class,remote interface, home interface and other classes which are used as
    parameters and return types.
    Regards
    Anilkumar kari

Maybe you are looking for

  • Acrobat 9.0 Pro

    PDFMaker cannot locate the Adobe PDF Printer's printer driver. Please reinstall Adobe Acrobat 9.0. I keep getting this message when I am trying to convert a file to pdf. There is not an Adobe PDF listed in my printers. I have tried to repair the inst

  • Problem with Z fields in VA01

    Hi, We have added a Z field to VA01 transaction header lever Additional Data B. When we try and create a order using VA01 it is working fine but when we try to record the transaction using SHDB we are unable to find the Z field in additional data B.

  • Not getting windows logon screen

    HP 4530s Win 7 64 bit Still dealing with the keyboard problems. After changing 3 keyboards, with 3 Case#'s, was told problem is probably in the software and before they would proceed I needed to return the system to the defaults (system restore from

  • Displaying the correct value of Y in page X of Y when running a batch

    Hi There Does anyone know how I can re-set the Y of page X of Y in the footer for each PO when running a batch? I am using <?for-each@section:G_HEADERS?> which is working great for each PO - re-setting the PO number in the header and re-setting the X

  • Net framework 4 doesnt work in boot camp, I needed to install autodesk product

    does anyone know the iso of window 7 affected the .net framework , or i needed a latest version of window 7 sp1 in order to make .net framework works ?My autodesk autocad 2012 doesnt continue installation due to this problem, although i have installe