Sunil Reddy Enugala

…..is just walking through MSBI Street.

Execute Java Class File from SSIS

Posted by Sunil Reddy Enugala on June 2, 2013

Hi, recently I came across interesting requirement through my friend Goutham Aakiti. The requirement is like processing Java Class file using SSIS. I was very curious to know how to achieve this, spent some time and found that there are two ways to process Java Class File.

Let me show how we can do this.

 

Prcoess 1:

I have a Java Class File which deletes a file. Please go through the below Java code which accepts file path as argument to delete a file.

image

If you compile the above Java Code, the compiler will generate binary code file which is called as Class File. We will be using the Java Class file further to delete file.

 image

Drag a Execute Process task component to the SSIS Control Flow designer pane

Create four variable to pass the property values dynamically.

imageVariable Descriptions

FilePath: Represents the path of the file which we are about to delete.

JavaClass: Represents the path of Java Class file which we use to delete a file.

JavaDir: Represents the path of Java.exe, which we use to execute Java Class file.

WorkingDir: Represents the Folder path of Java.exe.

Only variables like FilePath, JavaClass and JavaDir needs input. We need to set variable expression for WorkingDir variable.

Please go through the below figure to know about setting of variable expression for WorkingDir variable. Click on WorkingDir variable and select properties(press f4 ). Set the EvaluateExpression value to True. Set the Expression value as below.

SUBSTRING( @[User::JavaDir] , 1, LEN( @[User::JavaDir] )-FINDSTRING(REVERSE(@[User::JavaDir]),"\\",1)+1) 

image

Please go through the below figure to know about the property values of Execute Process task.

image

Executable property needs the path value of  Java.exe, we will be passing the value through JavaDir variable as an property expression.

Arguments property needs statement to execute the Java Class File.

WorkingDirectory property needs the folder path of Java.exe, we’ll be passing the value through WorkingDir variable.

Please go through the below figure to know about the setting of above properties values. Properties like Executable and WorkingDirectory will be getting values directly from variables like JavaDir and WorkingDir.

image

We need to set an expression for Arguments property, please go through the below figure to know about the setting of expression.

"-classpath " + SUBSTRING( @[User::JavaClass] , 1, LEN( @[User::JavaClass] )-FINDSTRING(REVERSE(@[User::JavaClass]),"\\",1)+1) + " "+SUBSTRING (@[User::JavaClass], LEN( @[User::JavaClass] ) – FINDSTRING( REVERSE( @[User::JavaClass] ), "\\", 1) + 2,  LEN (RIGHT( @[User::JavaClass], FINDSTRING( REVERSE( @[User::JavaClass] ), "\\", 1 ) – 1 ) ) – FINDSTRING( REVERSE( @[User::JavaClass] ), ".", 1 )  ) + " "+ @[User::FilePath]

image  

Lets see how it works.

I want to delete a file DelmeSoon.txt from path D:FileDeletion\DellmeSoon\

image

press f5 and see, the Java Class file will deletes the.

image

Let me know your comments and queries on my post.

About these ads

4 Responses to “Execute Java Class File from SSIS”

  1. […] Execute Java Class File from SSIS […]

  2. Power of SSIS!!!!!!

  3. […] Execute Java Class file from SSIS […]

  4. Sunilreddy said

    If any popups open while executing the task, you need to set the WindowStyle property of Execute Process Task to Hidden to block the popups.

Leave a Reply...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 654 other followers

%d bloggers like this: