Deprecated compiling error
Asked Answered
S

4

14

I'm trying to compile my Java program, however I am getting a "Deprecated File" error.

I normally compile the file by typing "Javac FileName.java", however I get an error saying:

FileName.java uses or overrides a depreacted API. Recompile with Xlint-deprecation for details.

What do I type into the command line to make it run?

Smidgen answered 26/4, 2013 at 14:43 Comment(6)
"Recompile with Xlint-deprecation for details."Fourinhand
But how do i "Recompile with Xlint-deprecation"?! – Tom Stock just now editSmidgen
Tom, you don't need to do it, it's just a warning. You'd be better off viewing the deprecated issues in your IDE than here. In short, you will still get a class file. Check the output path and it's there.Lucan
But why wont it run, if it's just a warning?Smidgen
Iv just realised how stupid ive been, thanks guys..Smidgen
I hope I answered your query. It will run, the compiler just wants you to know it found some deprecated code.Lucan
L
17

It's not an error, just a warning.

The compiler will still produce a class file and you will be able to run it. However, it's a good idea to address the warning, since using deprecated API could lead to more problems later on.

If you choose to see the warnings, you can do this:

javac -Xlint:deprecation FileName.java
Lucan answered 26/4, 2013 at 14:52 Comment(0)
A
5

If you don't have a deprecation

javac -Xlint Filename.java
Asel answered 14/8, 2018 at 21:53 Comment(1)
While this snippet may answer the authors question, you want to expand it a little bit and add some words and maybe documetation to the -Xlint keyword. Please edit your answer in that respect (also not, that this question is 5 years old and propably solved. IMHO there is no need to answer such an old question which already has a few answers)Middleweight
C
0

I was getting the same exception in running a gradlew build. I discovered that the path included Java 1.7 and my JAVA_HOME variable path had 1.8 specifed. Once I updated the path to 1.8, the build was successful.

Cottle answered 19/5, 2016 at 18:40 Comment(0)
C
0

Had the similar issue and setting the PATH to the correct file that contains the JDK worked. For windows, search environnement variables > select edit environnement variables > Enter JAVA_HOME as variable and set the value to the jdk file.

Cornelia answered 1/5, 2019 at 3:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.