How to use event or java to call extenal .bat file which located in windows server

Answered

Hi,

is it possible to call .bat file through script PX or java, and the script is located in external windows server

Agile User Asked on September 7, 2021 in Agile PLM (v9).
Add Comment
2 Answer(s)
Best answer

Hello,

It’s possible to execute a Windows batch file using Java’s Process Explorer API. Please see detailed information in the below articles, you should get good idea about how you can reuse these in calling a .bat file from you Script or Java PX.

Java – How to run Windows bat file – Mkyong.com

How do I run a batch file from my Java Application? – Stack Overflow

Agile Expert Answered on September 7, 2021.
Add Comment

Hi Swagoto,

thanks for the information.

suddenly i can not find “inernal custom action” to choose .jar file, how to add new jar in extention list ?

Agile User Answered on September 8, 2021.

You mean your java class is not available in the drop down of the Custom Action PX in the Java Client? Was it available before?

on September 8, 2021.

Yes, i edit java file and general .jar file, put in extension folder on the server.

and login JAVA Client to setup “process extension”,  can not see this one.

we only have two jar file before, now still work, i never setup it on JAVA Client, only update java code and jar.

on September 8, 2021.

Have you added your fully qualified class name in the IEventAction file, situated in the META-INF/services folder of your java project? And this file should be exported in your jar too

on September 8, 2021.

you mean the directory in D:\Agile\Agile93\integration\sdk , to find META-INF/services folder ?

i never see  file name like IEventAction, can you explian more details, thanks

on September 9, 2021.

Please refer to this section:

Developing Process Extensions (oracle.com)

on September 9, 2021.

Hi,

thanks, for information.

create text file under META-INF/services  in java (Eclips) tool

  1. edit  com.advtek.hello in this file, and
  2. edit  import com.agile.px.ICustomTable; in java file
  3. compile java file as .jar
  4. put .jar file to server “extension” folder
  5. login JavaClient and setup process extension, where can choose the internal custom action
on September 9, 2021.

Yes, seems to be good. Did it work? If not, please paste a screenshot of your project structure from Eclipse, as well of the ICustomAction text file.

on September 9, 2021.

i can choose the List of ICustomAction text file.

now i try to write the java code to call batch file.

on September 10, 2021.

Hi,

i call the batch by action bottom.

throw exception  >>  java.lang.ClassCastException: com.advtek.hello

what is mean ?

 

i use the java code like this:

 

public class hello {

public static void main(String[] args) {
{
try {
String[] command = {“cmd.exe”, “/d”, “Start”, “D:\\temp\\hello.bat”};
Process p = Runtime.getRuntime().exec(command);
} catch (IOException ex) {
}
}

}

}

 

on September 10, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.