Turn off the evil DOS window

zhaozj2021-02-16  58

Turn off the evil DOS window

People who have used Java know that every time you run a Java program, you can run a good DOS window, if you can run the WINDOWS program like IE, Office. Maybe someone will think that there is no DOS window when JBuilder is running, but it is a shell written with C or C , but unfortunately I don't have other languages, what should I do? In fact, as long as you are good at observation, research, there are many ways to solve. Here you give you 3 solutions, let your program say goodbye to the DOS window!

(1) Use JBuilder's housing: carefully observe the bin directory in the JBuilder installation directory (note that JBuilder8 is used as an example, the low version of JBuilder will be slightly different), you will find jbuilder.config, jbuilder.exe, jbuilderw. EXE and JDK.CONFIG 4 files, open the jdk.config file with Notepad, change the 15th line javapath ../jdk1.4/jre/bin/client/jvm.dll to the corresponding path of JDK1.4 on your machine It is also important to note that JDK1.4, because the previous version of JDK does not have a bin / client / jvm.dll file, you can use an absolute path, change it to JavaPath D: /jbuilder8/jdk1.4/jre/bin/client /jvm.dll, then change 21 line addpath ../jdk1.4/lib/tools.jar to your machine's corresponding path, such as AddPath D: /JBuilder8/JDK1.4/Lib/Tools.jar, other Need to modify and exit after the deployment. Open the jBuilder.config file with Notepad, add a line after addPath, add your classpath, such as AddBootpath. (I will put the class file and 4 files above in the same directory), then the best line Mainclass com.borland.jbuilder.jbuilder is changed to your main program, such as mainclass com.bhr.ioat.test, saves exit. Then double-click JBuilderw.exe to try, is there no DOS window. Note that if you want to modify the name of the above file, you must ensure that JBuilder.config, JBuilder.exe, JBuilderw.exe match match, such as change to Test.config, Test.exe, Testw.exe, anything Matching may not run your program. In fact, the jbuilder.config file is mainly the setting of ClassPath, you can delete a lot of content in accordance with you, stay with you slowly study.

(2) Pack your program into a JAR file: first to install JDK, pay attention to the installation file of the EXE, although you can use a Copy installed from other machines, but not here, why? Tell you later. After the JDK is installed, go to the DEMO / JFC / NotePad of the installation directory, double-click notepad.jar, how, is there a DOS window, secret where, two points. (1) JDK is associated with the JAR file in the installation process to the Javaw.exe file. What is javaw.exe? In fact, like Java.exe, there is no DOS window when running the program. (2) It is the JAR file, if you don't generate JAR, or first check the information. Unemploy NOTEPAD.JAR with Winzip, go to the Meta-Inf directory, open the Manifest.mf file, see it, there is a main-class: notepad, you can change it to your own class. It should be noted that main-class: There is a space behind, if less, you should don't come to your program. (3) Through Windows's Start Command: This is simple, write a batch file that starts your program, you must use the javaw command to run, and then add the start command before the javaw command, such as:

Set classpath =.% ClassPath%;

SET PATH = D: /JBUILDER8/JDK1.4/bin;% PATH%;

Start javaw com.bhr.ioat.test

But there is a problem, that is, the DOS window will flash, then turn it off, it is still possible to make it.

The above is just three methods, including the first method, you can take a non-three, and you can also be implemented using the outer casing of Intellj IDEA. Although the DOS window is gone, the exceptions of the process are also different. There are several ways to make up for this problem, (1) Redirect your output to the file; (2) Using log4j in the program to do log ( Be sure to have an exception in Catch to accommodate it). It is best to really need to go to the evil DOS window, just look at yourself.

转载请注明原文地址:https://www.9cbs.com/read-22913.html

New Post(0)