In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail for you how to make Win10 realize the self-boot of Java files. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
I. description of the problem
As I entered the pit of Win10, I found that the most unbearable thing about it is the mandatory system update, and the system update is so frequent that it is simply unbearable. As a result, for some Java files that you want to run all the time, the restart after each system update will cause the Java file to stop running.
There are also many blogs to solve this problem: create a bat file and put the shortcut in the C:\ ProgramData\ Microsoft\ Windows\ Start Menu\ Programs\ StartUp directory. This method requires the user to log in before it can start itself. No.
Using Instsrv.exe (you can install and remove services for the system), Srvany.exe (you can let the program run as a service), see this, you don't want to try, it's too troublesome.
II. Problem solving
The way to solve the problem is to create a computer task scheduler.
III. Preparatory work
For example, you need to boot the following file (CSDN.java).
Import java.io.*;/*** Created by Yngz_Miao on 2019/6/14.*/public class CSDN {public static void main (String [] args) {Writer wo = null; try {wo = new FileWriter ("loginfo.log"); wo.write ("Hello World!\ r\ n"); wo.flush ();} catch (IOException e) {e.printStackTrace ();}
The main logic is to look for the loginfo.log file in the current directory and recreate one if it doesn't exist. Then write Hello World! in the file. The logic is simple.
How do we run this java file? Press and hold shift in the current directory, right-click, choose to open the command window here, and enter the command in the command line window:
Javac CSDN.javajava CSDN
Incidentally, if there are Chinese characters in the java file, an error is likely to be reported, so you need to use the command at this time:
Javac-encoding utf-8 CSDN.javajava CSDN
If the java file contains the System.out.println program, the running GUI window of the java program is retained after running, which is obviously not what we want. At this point, you can use javaw to avoid:
Javac-encoding utf-8 CSDN.javajavaw CSDN
IV. Bat file
Bat file, which is similar to the shell script on Linux system. It is a batch file, an unformatted text file that contains one or more commands. To put it simply, to run the contents of the bat file is equivalent to running all the commands in it one by one.
Create a CSDN.bat file: @ echo offstart java CSDNexit double-click the bat file, which is equivalent to typing and running the sentence java CSDN on the command line.
5. Set the bat file to boot automatically
1. Right-click computer-> manage, and select system tools-> schedule task program.
2. Select create Task. In the pop-up window, enter the task name and choose to run regardless of whether the user is logged in or not-> run with the highest permissions.
3. Switch to the trigger page, and when you start the task, check the delayed task time (wait for some system initialization to avoid errors)
4. Switch to the operation page, manipulate and select the startup program, locate the bat file that needs to be operated, and determine the location from which to start (that is, start the command line in that directory)
5. The conditions and settings page will be adjusted according to your personal habits, and finally enter the password for confirmation.
This completes the startup of the JAVA file, this article is aimed at a simple Java file, if it is a slightly more complex Java project, you can generate the entire project Jar file, and then use the command: java-jar CSDN.jar and then write the corresponding bat file, and then reset the task plan.
On "how to enable Win10 to achieve Java file boot self-startup" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.