run Talend ETL jobs from java application

Four Stars

run Talend ETL jobs from java application

i am working on a web application for log management , so i want to know how to run a Talend ETL job ( which will import a log file , treat it , extract relevent fields and load it into a DB) from my java web application . 

I want to explain more : i beuild an interface using angular which contains a "import" button , i want that whenever i click on that button ( which will call a method on my java application) the ETL job that i've created in Talend, runs automatically and the data is loaded into the data base . 

I 'll be really gratefull if you help me out

Sixteen Stars

Re: run Talend ETL jobs from java application

I use this technique in a couple of jobs.


1) First of all you need to build your Job.

2) Once you are happy with it, "build it" (right click "Build Job") and find the Job Jar in the zip file. You will need this for your Java application.

3) Write your Java application and import your Job library (you may need to play around with dependencies to get this 100% correct).

4) Now you simply need to run your Job. Here is some Java code I use to start a particular job that I use for analysing my Talend source files ....


//Create an ArrayList to hold parameter values (context params)
java.util.List<String> paraList = new java.util.ArrayList<String>();

//Add JobPath context param
paraList.add("--context_param JobPath="+"/Applications/Development/Talend/6.2.1/studio/workspace/LOCAL_PROJECT/process/Framework/ControllerJobs/ExecuteLoad_0.1.item");

//Add JobName context param
paraList.add("--context_param JobName="+"ExecuteLoad");

//Add UpdateTalendWorkspaceDataFile context param
paraList.add("--context_param UpdateTalendWorkspaceDataFile="+"true");

//Add WorkspaceProjectPath context param
paraList.add("--context_param WorkspaceProjectPath="+"/Applications/Development/Talend/6.2.1/studio/workspace/LOCAL_PROJECT");

//Add DataFile context param
paraList.add("--context_param DataFile="+"/Users/richardhall/Documents/test.xls");

//Create instance of Talend job
CalculateJobDependencies2 test = new CalculateJobDependencies2();

//Add params to Job and run it!
test.runJobInTOS((String[]) paraList.toArray(new String[paraList.size()]));

If you follow that, it should work for you after you have figured out library dependencies. Remember, this code is specific to my Job and my Job's context variables. Keep that in mind while you are extrapolating from this.


Good luck :-)