Use Arduino (and Java application) to change source of power

You can write a Java program to send data to an Arduino and the Arduino can act on that data.

I am not sufficiently familiar with Java to suggest suitable code (actually I avoid it if I can).

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text. It will be straightforward to make your Java program send data in a compatible format.

...R