Server Administration > Automate Tasks and Calculate Data Using Event Triggers > Using Event Triggers to Run Custom Java Code
  
Using Event Triggers to Run Custom Java Code
You can also use server-side event triggers to run custom Java code from a script.
Your custom Java code can be put into the installdir/data/java/classes directory as individual class files or packaged as one or more JAR files in the data/java/jars directory. You can use both directories at the same time if you want some classes packaged up and some exposed individually
Example
//
// Integrity sample script.
//
// This script runs a custom java code in com.abc.custom.
//
function run
{
Packages.com.abc.custom.CopyFile;
}

var eb = bsf.lookupBean("siEnvironmentBean");

print("TRIGGER SCRIPT echo.js: Event Type: " + eb.getEventName()
+ ", " + eb.getEventType() + ", " + eb.getEventContext());
* 
Custom Java code runs inside the Windchill RV&S server JVM and therefore can impact server performance. Code that runs computationally intensive activities can degrade server performance.
Additional information on server-side event triggers is provided in the installed Javadocs in:
installdir/data/documentation/javadocs/triggers/index.html
You can also link the Javadocs from the Windchill RV&S server home page. To view the Javadocs, click the link for Event Trigger Java Documentation displayed under Documentation.
The Javadocs provide API documentation that includes overview information, packages, classes, class hierarchies, deprecated APIs, and index information.
Key Considerations
JavaScript is not Java – what works in Java may not work in JavaScript. Note the following differences:
JavaScript
Java
Not object-oriented
Object-oriented language
Not compiled, runs interpretively
Is compiled
Tries to continue running on errors
Exceptions raised on errors
Variable declaration is optional
Variables must be declared
Variables can change data type
Variables cannot change data type
Functions are used
Methods are used
Little encapsulation – only function variables are private
Full range of encapsulation (public, protected, private) for methods and variables
Using Java Classes