I was also new to java this year so I am glad to finally be on the opposite end of the question for once. All you need to do is put your compressor inside of whatever class you have extending iterative robot. Inside the robotInit method put in compressor.start(). Then leave the shutting off part to your pressure switch. Now make a subsystem for the piston you are using (for me I call ours ShootPiston). Inside the subsystem make two Solenoid objects (one for extend and one for retract). Make three methods (extend, retract, stop) and set the solenoid objects using their set method to true or false depending on what each one is doing. Then make commands to extend and retract and in there call each method respectively. If you need more help with this or if I wasn’t clear let me know.