Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to running an existing Job in Java

  1. #1
    Join Date
    Mar 2009
    Posts
    12

    Default How to running an existing Job in Java

    I have an existing job and i would like to integrate it in a java program..
    how can i do??
    I try to do like transformation but it doesn't work..

    can someone help me?

  2. #2

    Default

    u can use the given code.

    public static void runJob(String filename)
    {
    filename="E:\\Projects\\Whiteny\\KETTLE\\KETTLE\\XML\\ProvisioningOracle.xml";
    try {
    StepLoader.init();
    JobEntryLoader.init();
    StepLoader stepLoader = StepLoader.getInstance();
    LogWriter logWriter = null;
    try {
    logWriter = LogWriter.getInstance(LogWriter.LOG_LEVEL_BASIC); //$NON-NLS-1$
    } catch (Throwable t) {

    }
    JobMeta jobMeta = new JobMeta(logWriter,filename.toString(),null,null);
    Job job = new Job(logWriter, stepLoader, null, jobMeta);
    job.getJobMeta().setArguments(null);
    job.initializeVariablesFrom(null);
    job.getJobMeta().setInternalKettleVariables(job);
    //job.execute(); // You can pass arguments instead of null.
    Result result = job.execute(); // Execute the selected job.
    job.endProcessing(Database.LOG_STATUS_END, result); // The bookkeeping...
    job.waitUntilFinished();
    if ( job.getErrors() > 0 )
    {
    throw new RuntimeException( "There were errors during transformation execution." );
    }
    }
    catch ( KettleException e ) {
    // TODO Put your exception-handling code here.
    System.out.println(e);
    }

    }

  3. #3
    Join Date
    Mar 2009
    Posts
    12

    Default

    thank you... I've done it with your suggestion!

  4. #4
    Join Date
    Apr 2007
    Posts
    8

    Default

    I solved the problem that I asked before. The new problem is: Now I'm using the Java code to execute my transformation (not a job) and it works. My transformation get an excel file in input. I want to pass to my program in java one by one a list of excel file. It should get this file and then recall the transformation passing each file. They have the same layout. Could you help me do do this?Thank you.

    Ani
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.