When you use Java commands for the first time to run a Java program, the system sometimes throws the error message "class name is accepted only when explicit request annotation is processed". why and how can this problem be solved.
See the following code:
Import javax. swing. jframe; <br/> Import javax. swing. jbutton; <br/> public class myframe extends javax. swing. jframe {<br/> jbutton = NULL; <br/> Public myframe () {<br/> initbutton (); <br/> Add (button ); <br/> This. setsize (400,400); <br/> This. show (); <br/>}</P> <p> private void initbutton () {<br/> If (Button = NULL) {<br/> button = new jbutton ("OK"); <br/>}< br/> Public static void main (string [] ARGs) {<br/> New myframe (); <br/>}< br/>
This code is actually very easy to put a jbutton in a jframe.
Use javac to compile and generate class
When running in Java, "class names are accepted only when explicit request annotation is processed" is reported ".
In fact, the reason is very simple, because the show method is an outdated method. Solution:
The following prompt is displayed when you use javac to compile the class:
Note: myframe. Java uses or overwrites outdated APIs.
Note: For details, use-xlint: deprecation to re-compile.
Next, we only need to recompile the code using this method:
Javac-xlint: deprecation myframe. Java
The list of expired methods will be listed after execution, which can be ignored as long as the class file is correctly compiled
The above error message is not displayed when you run the class file using the Java command.
The solution is very simple. Many people have asked such questions on the Internet, but there are very few answers to the questions. Therefore, we will analyze the problems and then think about them.
End