Any specific reason why you want to do it the hard way with a Java action? I would suggest using a nano or microflow for this or just show the shopping card in a grid and use the aggregate function. See the documentation here: https://docs.mendix.com/refguide/columns/#243-aggregate-function
You could use the generated Java proxy classes to interact with entities and their attributes, but as Ronald says, why would you want to do it the hard way? It would be far easier to implement this directly in Mendix. If you do this in a microflow it will compile down to bytecode to run on the JVM.