The most correct method is to run Java with bat without displaying the DOS window (not even flashing)

Source: Internet
Author: User

Today, I wrote a SWT tool independent of the RCP project, which needs to be started using batch processing. I even wrote a batch processing window without flashing dos. I think my colleagues are stunned. So I will share my experiences with you.


Many friends use batch processing in Windows to start their own Java programs,
The general statement is:
Run class:

Java xx


Run jar:

Java-jar XXX. Jar

However, a disgusting dialog box stops until we close the program.



So many people say they can do this.

Run class:

Start javaw xx

Run jar:

Start javaw-jar XXX. Jar


In this way, the DOS window will still flash. Does this solve the problem ?! Many people on the Internet say yes.

For those of us who are pursuing perfection, it is still unacceptable.


So the ultimate solution came into being!

Add @ echo off to the first line of batch processing.


In this way, our batch processing becomes


Run class:
@ Echo off

Start javaw xx


Run jar:
@ Echo off

Start javaw-jar XXX. Jar



Try it. It's never a flash. Hahaha.


Explain
Echo off
Indicates that the command line itself is not displayed for all running commands after this statement.
@ Indicates that this command line is not displayed during running



I think that when I was playing a game version D, the virtual optical drive was still a command line method. In order to make a game run normally, I often had to write a long batch of processing, at that time, such perfectionists realized the importance of @ echo off.

This proves how wise and great it is to say that it is to learn dos well.

Reprinted:

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.