At least for Oracle's JDK (not sure about OpenJDK): install either the oracle-java7-set-default
or the oracle-java8-set-default
package, depending on which java version you want to be the default on your system.
You can get it from: http://ppa.launchpad.net/webupd8team/java/ubuntu (including the actual Oracle JDKs) See: https://launchpad.net/~webupd8team/+archive/java
Alternatively you could set the PATH and JAVA_HOME environment variables e.g. in /etc/environment
That said, when you compile you could specify the source and target level to 1.7, which would generate Java SE 7 compatible bytecode also when using JDK 8. But note it won't check if you're using some API not available in Java SE 7.
For this reason I recommend to use always the JDK version you target rather than doing some cross-compiling (which would need some additional extra steps to do it right).
Note however that you can install several JDK versions on your systems. IDEs usually let you choose which one you want to use during development.