I am using IntelliJ IDEA Community Edition for the first time and using Maven to set up a TDD environment. The code that I am trying to test and the warning messages I had encountered along with the project structure are provided below.
package miscellaneous; import org.junit.Test; import static org.junit.Assert.*; public class TestHello { // Methods to be tested..... private int Add1Plus1(int i, int j) { return (i + j); } @Test public void testAdd1Plus1() throws Exception { assertEquals(2, Add1Plus1(1, 1)); } }
Warning:java: source value 1.5 is obsolete and will be removed in a future release Warning:java: target value 1.5 is obsolete and will be removed in a future release Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.
What is causing these messages and what would be a good/recommended way to fix these warning messages?
From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Project Settings | Modules. Select the necessary module and then open the Sources tab in the right-hand part of the dialog.
Press ⌥F7 (macOS), or Alt+F7 (Windows/Linux), to bring up the Find Usages tool window. You can search a single file, your whole project, or customise the scope. You can also configure the color of the usages highlighting or disable the automatic highlighting of usages.
Check java version in your pom.xml(here you can find how to do it). Also check java version in Project Structure. And the last what you can do - check compiler version e.g.
I did all of the above and still had one instance of the warning:
Warning:java: source value 1.5 is obsolete and will be removed in a future release
I went into my project_name.iml file and replaced the following tag:
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
with:
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
And voila, no more error message. Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With