12 Replies Latest reply: Sep 7, 2012 5:20 AM by Bhabani Ranjan RSS

    calling jar file

    vai
      how to call a jar file in ODI procedure or how to to make use of java code in ODI?
        • 1. Re: calling jar file
          Sutirtha Roy
          Place the jar file in ODI_HOME/drivers directory .
          Make sure that your classpath has an entry to the ODI_HOME/drivers path.
          Restart your ODI agent.
          • 2. Re: calling jar file
            vai
            Thanks for the reply, but can u please suggest how to set classpath for <ODIHOME>\drivers path
            • 3. Re: calling jar file
              Sutirtha Roy
              vaibhav wrote:
              Thanks for the reply, but can u please suggest how to set classpath for <ODIHOME>\drivers path
              Open odiparams.sh/bat file ( located at <ODIHOME>\bin) , you shoud find entry for ODI_CLASSPATH
              You need to verify that it has the path for <ODIHOME>\drivers directory ( normally it does )
              If it is already there then you do not have to do any modification and restarting odi agent will load the newly added jar file in odi.
              • 4. Re: calling jar file
                vai
                i am creating a jar file for the following code-

                import java.io.*;

                public class FileWrite

                {
                public void writeFile()
                {
                FileOutputStream fos;
                DataOutputStream dos;
                try {

                File file= new File("D:\\MyFile.txt");
                fos = new FileOutputStream(file);

                dos=new DataOutputStream(fos);

                dos.writeInt(2333);

                dos.writeChars("Hello World");

                } catch (IOException e) {

                e.printStackTrace();

                }

                }
                }
                }


                I am creating a procedure with "Java bean Shell" technology
                And in the code m writing the following code-
                -------------------------------
                import FileWrite;

                FileWriter fw=new FileWriter();
                fw.writeFile();
                -------------------------------

                when i am executing the procedure, the procedure executes well but it does not writes the content into the file, what is going wrong in the code??
                • 5. Re: calling jar file
                  Sutirtha Roy
                  Befor calling the jar file via jython/java bean , did you try it out via any java program outside of ODI ?
                  Is it working properly ?
                  • 6. Re: calling jar file
                    vai
                    Yes, the java code is working when executing normally via command prompt.
                    It creates a new file and then appends the string.
                    • 7. Re: calling jar file
                      Bhabani Ranjan
                      I am creating a procedure with "Java bean Shell" technology
                      And in the code m writing the following code-
                      -------------------------------
                      import FileWrite;

                      FileWriter fw=new FileWriter();
                      fw.writeFile();
                      -------------------------------
                      How come you write without passing the filename ??? It should be like this.
                      FileWriter fw = new FileWriter("file1.txt");
                      • 8. Re: calling jar file
                        Sutirtha Roy
                        Bhabani wrote:
                        I am creating a procedure with "Java bean Shell" technology
                        And in the code m writing the following code-
                        -------------------------------
                        import FileWrite;

                        FileWriter fw=new FileWriter();
                        fw.writeFile();
                        -------------------------------
                        How come you write without passing the filename ??? It should be like this.
                        FileWriter fw = new FileWriter("file1.txt");
                        The file name is hardcoded in the java code as MyFile.txt
                        • 9. Re: calling jar file
                          Sutirtha Roy
                          Bhabani wrote:
                          I am creating a procedure with "Java bean Shell" technology
                          And in the code m writing the following code-
                          -------------------------------
                          import FileWrite;

                          FileWriter fw=new FileWriter();
                          fw.writeFile();
                          -------------------------------
                          How come you write without passing the filename ??? It should be like this.
                          FileWriter fw = new FileWriter("file1.txt");
                          The file name is hardcoded in the java code as MyFile.txt
                          • 10. Re: calling jar file
                            Sutirtha Roy
                            Bhabani wrote:
                            I am creating a procedure with "Java bean Shell" technology
                            And in the code m writing the following code-
                            -------------------------------
                            import FileWrite;

                            FileWriter fw=new FileWriter();
                            fw.writeFile();
                            -------------------------------
                            How come you write without passing the filename ??? It should be like this.
                            FileWriter fw = new FileWriter("file1.txt");
                            The file name is hardcoded in the java code as MyFile.txt
                            • 11. Re: calling jar file
                              Sutirtha Roy
                              Bhabani wrote:
                              I am creating a procedure with "Java bean Shell" technology
                              And in the code m writing the following code-
                              -------------------------------
                              import FileWrite;

                              FileWriter fw=new FileWriter();
                              fw.writeFile();
                              -------------------------------
                              How come you write without passing the filename ??? It should be like this.
                              FileWriter fw = new FileWriter("file1.txt");
                              The file name is hardcoded in the java code as MyFile.txt
                              • 12. Re: calling jar file
                                Bhabani Ranjan
                                Give me your email id. I will mail you the jar file.
                                Thanks.
                                http://bhabaniranjan.com/