Once you deploy the code for eclipse and open the java file in eclipse. You could see a method called "executeAction()". And in that method, you could find a lines with comment "// BEGIN USER CODE" and "// END USER CODE". And if you have to write any code, you need to write the logic between both the lines to make it work.
Hope this will resolve your issue!
Apart from adding import lines, the only place you can edit your Java Action code is between the comments marked // BEGIN USER CODE and // END USER CODE
Any other code in the Java Action file will be lost when you compile your application.
You can also add custom Java files for your Java Actions to call, and these won’t be changed when you rebuild your application or Deploy for Eclipse.
I hope this helps.