Java debug and release compilation methods

Source: Internet
Author: User

I have never noticed before. In fact, there are two ways to compile Java into. Class.

The default release method is javac, while the myeclipse tool we often use uses the debug mode.

The differences are as follows:

Function parameters change in release mode.

Test. Java

public class Test{private static void sayHello(){System.out.println("Hello world");}public static void main(String[] args){sayHello();}}

Use javac commands and myeclipse ide To compile test. Java

Then use jd-gui.exe to view test. Class

It can be found that the test. Class (below) generated by the javac command is different from the parameter name compiled by myeclipse (below ).

public class Test{  private static void sayHello()  {    System.out.println("Hello world");  }  public static void main(String[] args) {    sayHello();  }}
public class Test{  private static void sayHello()  {    System.out.println("Hello world");  }  public static void main(String[] paramArrayOfString) {    sayHello();  }}

This also explains why we recommend that you specify a name for the Controller annotation initialization parameter in spring MVC.

@RequestMapping(/test/{str})public String test(@PathVariable String str){     System.out.println(str);     return null;}

The actual project deployment uses the release version, so that STR is not the {STR} In requestmapping. Such problems won't be discovered during development.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.