CN112181544B - Java application running method, system and device and computer readable storage medium - Google Patents

Java application running method, system and device and computer readable storage medium Download PDF

Info

Publication number
CN112181544B
CN112181544B CN202011358276.9A CN202011358276A CN112181544B CN 112181544 B CN112181544 B CN 112181544B CN 202011358276 A CN202011358276 A CN 202011358276A CN 112181544 B CN112181544 B CN 112181544B
Authority
CN
China
Prior art keywords
script
java application
target
information
current thread
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011358276.9A
Other languages
Chinese (zh)
Other versions
CN112181544A (en
Inventor
陆庆尚
万振华
王颉
徐瑞祝
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Kaiyuan Internet Security Technology Co Ltd
Original Assignee
Shenzhen Kaiyuan Internet Security Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Kaiyuan Internet Security Technology Co Ltd filed Critical Shenzhen Kaiyuan Internet Security Technology Co Ltd
Priority to CN202011358276.9A priority Critical patent/CN112181544B/en
Publication of CN112181544A publication Critical patent/CN112181544A/en
Application granted granted Critical
Publication of CN112181544B publication Critical patent/CN112181544B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a method, a system and a device for running Java application and a computer readable storage medium, wherein the method comprises the following steps: calling a starting script by a current thread of the Java application, generating a process state file, and writing first state information into the process state file; starting a script to call a target executable program or script; writing the execution result information of the target subprocess started by the target executable program or script into a process state file; after the start script is called, the current thread reads state information from the process state file at a preset first time interval; and when the current thread reads the execution result information of the target subprocess, the Java application enters subsequent operation. Based on the method, the time interval can be set by self-definition to read the running condition of the target subprocess, so that the running condition of the process can be timely and accurately acquired to perform subsequent operation. In addition, the method is simple, has low requirement on the operating environment, and is suitable for various different operating systems or machines.

Description

Java application running method, system and device and computer readable storage medium
Technical Field
The present invention relates to the field of Java technologies, and in particular, to a method, a system, an apparatus, and a computer-readable storage medium for running Java applications.
Background
When writing an application in Java, it is often necessary to call another ready-made executable program or system command in the program, and theoretically, the execution results will be consistent, but in the course of actual use, the difference of the operating environments will have a certain influence on the execution results, for example, Windows operating systems of the same version execute the same batch processing script on different machines, and call the same target program, the result may be inconsistent, and most machines can achieve the effect that the current thread is blocked until the sub-process task is completed, but some machines continue to execute downward if the sub-process task is not completed. And the current Java application is difficult to know the execution condition of each subprocess task timely and accurately when running, and when the subprocess task is abnormal, the abnormal subprocess can not be positioned quickly and accurately.
Disclosure of Invention
The present invention provides a method, a system, an apparatus, and a computer readable storage medium for running a Java application, which can effectively avoid the situation that a subprocess is not completed and is continuously executed in various running environments, and can quickly and accurately locate an abnormal subprocess.
In order to achieve the above object, the present invention discloses a method for running a Java application, comprising:
calling a start script by a current thread of the Java application, wherein the start script is provided with a corresponding relation between each thread of the Java application and each target executable program or script;
the starting script generates a process state file and writes first state information into the process state file, wherein the first state information comprises initialization state information of the starting script and running state information generated after initialization is completed and before a corresponding target executable program or script is called;
the starting script calls the target executable program or script corresponding to the current thread, and the target executable program or script starts a target subprocess;
writing the execution result information of the target subprocess serving as second state information into the process state file;
after the start script is called, the current thread reads state information from the process state file at a preset first time interval;
and when the current thread reads the execution result information of the target sub-process, the Java application enters subsequent operation.
Preferably, the running method of the Java application further comprises:
after the start script is called, the current thread searches whether the target subprocess exists or not according to the identification information at a preset second time interval;
if the target sub-process exists, the current thread continues to read state information from the process state file at the preset first time interval;
if the target subprocess does not exist, the Java application enters subsequent operation;
the preset second time interval is greater than the preset first time interval.
Preferably, the running method of the Java application further comprises:
and the starting script generates a log file after being called, and the log file records the running information of the starting script and the running information of the target subprocess.
Preferably, the execution result of the target sub-process is output in the form of a return value, and the output return value is compiled to form the execution result information and written into the process state file.
In order to achieve the above object, the present invention further discloses a Java application execution system, which includes:
the system comprises a first calling module, a second calling module and a third calling module, wherein the first calling module is used for calling a starting script by a current thread of the Java application, and the starting script is provided with a corresponding relation between each thread of the Java application and each target executable program or script;
a generating module, configured to generate a process state file by the start script, and write first state information into the process state file, where the first state information includes initialization state information of the start script and running state information generated after initialization is completed and before a corresponding target executable program or script is called;
the second calling module is used for calling the target executable program or script corresponding to the current thread by the starting script, and the target executable program or script starts a target subprocess;
a write-in module, configured to write execution result information of the target sub-process as second state information into the process state file;
the first reading module is used for reading state information from the process state file by the current thread at a preset first time interval after the start script is called;
and the first entering module is used for entering the subsequent operation of the Java application when the current thread reads the execution result information of the target subprocess.
Preferably, the operation system further includes:
the detection module is used for searching whether the target subprocess exists or not by the current thread at a preset second time interval according to the identification information after the start script is called;
a second reading module, configured to, if the target sub-process exists, continue to read state information from the process state file at the preset first time interval by the current thread;
the second entering module is used for entering the subsequent operation of the Java application if the target subprocess does not exist;
the preset second time interval is greater than the preset first time interval.
Preferably, the start script generates a log file after being called, and the log file records the running information of the start script and the running information of the target sub-process.
Preferably, the execution result of the target sub-process is output in the form of a return value, and the output return value is compiled to form the execution result information and written into the process state file.
In order to achieve the above object, the present invention further discloses a running device of a Java application, comprising:
one or more processors;
a memory; and
one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising instructions for performing the execution method of the Java application as described above.
In order to achieve the above object, the present invention further discloses a computer readable storage medium, which includes a computer program for testing, the computer program being executable by a processor to perform the method for running the Java application as described above.
Compared with the prior art, by using the running method or the running system of the Java application, the starting script can be called through the current thread of the Java application to generate a process state file, and the initialization state information and the running state information can be written into the process state file; then, calling a target executable program or script corresponding to the current thread by the starting script, and writing the execution result information of the target subprocess started by the target executable program or script into a process state file; after the start script is called, the current thread reads state information from the process state file at a preset first time interval; when the current thread reads the execution result information of the target subprocess, the Java application enters subsequent operation; therefore, by the method, the current thread of the Java application can timely and accurately monitor the running state of the target subprocess and can enable the Java application to enter subsequent operation when the execution result information of the target subprocess is read.
Drawings
Fig. 1 is a flowchart illustrating a method for running a Java application according to an embodiment of the present invention.
Fig. 2 is a schematic structural diagram of a running system of a Java application according to an embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an operating apparatus of a Java application according to an embodiment of the present invention.
Detailed Description
In order to explain technical contents, structural features, implementation principles, and objects and effects of the present invention in detail, the following detailed description is given with reference to the accompanying drawings in combination with the embodiments.
Referring to fig. 1, the present invention discloses a method for running a Java application, which includes the following steps.
And S1, calling the start script by the current thread of the Java application, wherein the start script is provided with the corresponding relation between each thread of the Java application and each target executable program or script.
S2, the start script generates a process state file, and writes first state information into the process state file, where the first state information includes initialization state information of the start script and running state information generated after the initialization is completed and before the corresponding target executable program or script is called.
Specifically, in the operating system supported by Java, such as window, Linux, macOs, etc., the start script may be a bat script in window, a shell script in Linux, and a function for generating a process state file is defined in the start script. The target sub-process corresponds to a monitoring task, meanwhile, one monitoring task has a unique identifier, and the function generates a corresponding process state file according to the identifier of the monitoring task. After the process state file is generated, the first state information may be written into the process state file via an I/O operation. The first state information can be specifically divided into an initialization state and an operating state, the initialization state refers to initializing relevant environments or parameters, meanwhile, the script is started to search whether a target executable program or the script is in a specified directory, if the process state file does not exist, the target executable program or the script is updated to be in a failure state, and if the process state file does not exist, the target executable program or the script continues to be executed downwards. The running state refers to that the target program is in execution, and in this embodiment, after the initialization state is set, and before the start script calls the target executable program, the running state is written into the process state file, and the running state continues until the execution result of the target sub-process is generated.
S3, the start script calls the target executable program or script corresponding to the current thread, and the target executable program or script starts the target subprocess.
And S4, writing the execution result information of the target sub-process into the process state file as second state information.
Specifically, the second state information includes execution success and execution failure. Execution may also be considered to fail when other error conditions occur.
And S5, after the start script is called, the current thread reads the state information from the process state file at a preset first time interval.
Specifically, the content of the process state file is read by an I/O operation according to a first time period set by a user to acquire state information.
And S6, when the current thread reads the execution result information of the target sub-process, the Java application enters subsequent operation.
For the method for operating the Java application disclosed in the above embodiment, the start script is called through the current thread of the Java application to generate a process state file, and the initialization state information and the running state information can be written into the process state file; then, calling a target executable program or script corresponding to the current thread by the starting script, and writing the execution result information of the target subprocess started by the target executable program or script into a process state file; after the start script is called, the current thread reads state information from the process state file at a preset first time interval; when the current thread reads the execution result information of the target subprocess, the Java application enters subsequent operation; therefore, by the method, the current thread of the Java application can timely and accurately monitor the running state of the target subprocess and can enable the Java application to enter subsequent operation when the execution result information of the target subprocess is read.
Further, the method for running the Java application in the above embodiment further includes:
after the start script is called, the current thread searches whether a target subprocess exists or not according to the identification information at a preset second time interval;
if the target subprocess exists, the current thread continues to read the state information from the process state file at a preset first time interval;
if the target subprocess does not exist, the Java application enters subsequent operation;
the preset second time interval is greater than the preset first time interval.
By the method, when the target subprocess exits due to abnormity and the corresponding state is not recorded, whether the target subprocess exists or not can be searched according to the identification information through the preset second time interval, and corresponding subsequent operations can be respectively carried out according to the condition whether the target subprocess exists or not. Specifically, the first time interval and the second time interval may start timing at the same time, and the user may set the first time interval and the second time interval in a user-defined manner according to a requirement, for example, the first time interval may be set to 5 seconds, and the second time interval may be set to 10 minutes, so that the current thread may search for the target sub-process according to the identifier every 10 minutes, and if the target sub-process exists, continue to read the state information from the process state file at the first time interval.
Furthermore, the start script generates a log file after being called, and the log file records the running information of the start script and the running information of the target sub-process. Preferably, the log file may record only the output information of the target sub-process and the start-up script. By the method, a user can clearly know the respective operation information and the state information of the starting script and the target subprocess by checking the content of the log file, and can record error information, such as that the target subprocess cannot be found, or the target subprocess is started to report errors. By generating the log file and recording the running information, the user can be conveniently provided with clear understanding of the process positioning condition.
Preferably, the execution result of the target sub-process is output in the form of a return value, and the output return value is compiled to form execution result information and written into the process state file. The execution result is output in the form of a return value, and the return value is compiled into corresponding execution result information, so that the execution can be smoothly executed under various operating environments. Specifically, the execution result of the target sub-process may generally be an execution success and an execution failure, where the execution success is denoted as 0, and the execution failure is denoted as 1, and when other error conditions occur, the error conditions may also be regarded as the execution failures, and the multiple execution conditions are simplified into two (the execution success is denoted as 0, the execution failure is denoted as 1, and other conditions are denoted as 1), so that the workload requirement of the execution environment may be reduced, and then the return value is compiled into corresponding execution result information, which is convenient for the user to read, and the user may quickly know the execution result information of the target sub-process.
Referring to fig. 2, the present invention also discloses a Java application operating system, which includes:
a first calling module 10, configured to call a start script by using a current thread of the Java application, where the start script is provided with a correspondence between each thread of the Java application and each target executable program or script;
a generating module 11, configured to start a script to generate a process state file, and write first state information into the process state file, where the first state information includes initialization state information of the start script and running state information generated after initialization is completed and before a corresponding target executable program or script is called;
the second calling module 12 is configured to start a script to call a target executable program or script corresponding to the current thread, where the target executable program or script starts a target sub-process;
a writing module 13, configured to write execution result information of the target sub-process as second state information into the process state file;
the first reading module 14 is configured to read, after the start script is called, state information from the process state file at a preset first time interval by the current thread;
and the first entering module 15 is used for the Java application to enter subsequent operations when the current thread reads the execution result information of the target sub-process.
Preferably, the operation system further comprises:
the detection module is used for searching whether the target subprocess exists or not by the current thread at a preset second time interval according to the identification information after calling the start script;
the second reading module is used for continuously reading the state information from the process state file by the current thread at a preset first time interval if the target subprocess exists;
the second entering module is used for entering the subsequent operation of the Java application if the target subprocess does not exist;
the preset second time interval is greater than the preset first time interval.
Preferably, the start script generates a log file after being called, and the log file records the running information of the start script and the running information of the target sub-process.
Preferably, the execution result of the target sub-process is output in the form of a return value, and the output return value is compiled to form execution result information and written into the process state file.
The specific working process of the running system of the fast Java application is detailed in the running method of the Java application, and is not described herein again.
Referring to fig. 3, the present invention also discloses a Java application execution apparatus, which includes one or more processors 21, a memory 20, and one or more programs, wherein the one or more programs are stored in the memory 20 and configured to be executed by the one or more processors 21, and the program includes instructions for executing the Java application execution method.
Finally, the invention also discloses a computer readable storage medium, which comprises a computer program for testing, wherein the computer program can be executed by a processor to complete the running method of the Java application.
The above disclosure is only a preferred embodiment of the present invention, and certainly should not be taken as limiting the scope of the present invention, which is therefore intended to cover all equivalent changes and modifications within the scope of the present invention.

Claims (10)

1. A method for running a Java application is characterized by comprising the following steps:
calling a start script by a current thread of the Java application, wherein the start script is provided with a corresponding relation between each thread of the Java application and each target executable program or script;
the starting script generates a process state file and writes first state information into the process state file, wherein the first state information comprises initialization state information of the starting script and running state information generated after initialization is completed and before a corresponding target executable program or script is called;
the starting script calls the target executable program or script corresponding to the current thread, and the target executable program or script starts a target subprocess;
writing the execution result information of the target subprocess into the process state file as second state information, wherein the second state information comprises execution success and execution failure;
after the start script is called, the current thread reads state information from the process state file at a preset first time interval;
and when the current thread reads the execution result information of the target sub-process, the Java application enters subsequent operation.
2. The method for executing a Java application according to claim 1, further comprising:
after the start script is called, the current thread searches whether the target subprocess exists or not according to the identification information at a preset second time interval;
if the target sub-process exists, the current thread continues to read state information from the process state file at the preset first time interval;
if the target subprocess does not exist, the Java application enters subsequent operation;
the preset second time interval is greater than the preset first time interval.
3. The method for executing a Java application according to claim 1, further comprising:
and the starting script generates a log file after being called, and the log file records the running information of the starting script and the running information of the target subprocess.
4. The method for executing a Java application according to claim 1, wherein the execution result of the target sub-process is output in the form of a return value, and the output return value is compiled to form the execution result information and written into the process state file.
5. A Java application execution system, comprising:
the system comprises a first calling module, a second calling module and a third calling module, wherein the first calling module is used for calling a starting script by a current thread of the Java application, and the starting script is provided with a corresponding relation between each thread of the Java application and each target executable program or script;
a generating module, configured to generate a process state file by the start script, and write first state information into the process state file, where the first state information includes initialization state information of the start script and running state information generated after initialization is completed and before a corresponding target executable program or script is called;
the second calling module is used for calling the target executable program or script corresponding to the current thread by the starting script, and the target executable program or script starts a target subprocess;
a writing module, configured to write execution result information of the target sub-process into the process state file as second state information, where the second state information includes an execution success and an execution failure;
the first reading module is used for reading state information from the process state file by the current thread at a preset first time interval after the start script is called;
and the first entering module is used for entering the subsequent operation of the Java application when the current thread reads the execution result information of the target subprocess.
6. The execution system of a Java application according to claim 5, further comprising:
the detection module is used for searching whether the target subprocess exists or not by the current thread at a preset second time interval according to the identification information after the start script is called;
a second reading module, configured to, if the target sub-process exists, continue to read state information from the process state file at the preset first time interval by the current thread;
the second entering module is used for entering the subsequent operation of the Java application if the target subprocess does not exist;
the preset second time interval is greater than the preset first time interval.
7. The Java application execution system of claim 5, wherein the start script generates a log file after being called, and the log file records the execution information of the start script and the execution information of the target sub-process.
8. A running system for a Java application according to claim 5, wherein the execution result of the target sub-process is output in the form of a return value, and the output return value is compiled to form the execution result information and written in the process state file.
9. An apparatus for running a Java application, comprising:
one or more processors;
a memory;
and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising instructions for performing the method for operating the Java application according to any of claims 1 to 4.
10. A computer-readable storage medium comprising a computer program for testing, the computer program being executable by a processor to perform a method of running a Java application according to any one of claims 1 to 4.
CN202011358276.9A 2020-11-27 2020-11-27 Java application running method, system and device and computer readable storage medium Active CN112181544B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011358276.9A CN112181544B (en) 2020-11-27 2020-11-27 Java application running method, system and device and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011358276.9A CN112181544B (en) 2020-11-27 2020-11-27 Java application running method, system and device and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN112181544A CN112181544A (en) 2021-01-05
CN112181544B true CN112181544B (en) 2021-03-26

Family

ID=73918161

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011358276.9A Active CN112181544B (en) 2020-11-27 2020-11-27 Java application running method, system and device and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN112181544B (en)

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102200941A (en) * 2010-03-25 2011-09-28 杭州华三通信技术有限公司 Method and unit for monitoring process state
US10296297B2 (en) * 2013-08-09 2019-05-21 Oracle International Corporation Execution semantics for sub-processes in BPEL
CN107239377B (en) * 2016-03-29 2021-02-26 阿里巴巴集团控股有限公司 Method and device for acquiring running state of Java virtual machine
CN107193712A (en) * 2017-06-01 2017-09-22 北京匡恩网络科技有限责任公司 A kind of method and apparatus for management of process
CN107832100B (en) * 2017-10-27 2020-12-04 平安普惠企业管理有限公司 APK plug-in loading method and terminal thereof
CN109408158B (en) * 2018-11-06 2022-11-18 恒生电子股份有限公司 Method and device for quitting child process along with parent process, storage medium and electronic equipment
CN111625428A (en) * 2020-04-20 2020-09-04 中国建设银行股份有限公司 Method, system, device and storage medium for monitoring running state of Java application program
CN111913851A (en) * 2020-07-31 2020-11-10 平安科技(深圳)有限公司 Process monitoring method, system, terminal and storage medium

Also Published As

Publication number Publication date
CN112181544A (en) 2021-01-05

Similar Documents

Publication Publication Date Title
US8250543B2 (en) Software tracing
US8930915B2 (en) System and method for mitigating repeated crashes of an application resulting from supplemental code
US8438424B2 (en) Assessing computer programs using stack frame signatures
US7991961B1 (en) Low-overhead run-time memory leak detection and recovery
US7774761B2 (en) Use of memory watch points and a debugger to improve analysis of runtime memory access errors
US8756569B2 (en) Deterministic pseudo-random fault event recordation and injection tool
US11422920B2 (en) Debugging multiple instances of code using thread patterns
US7765434B2 (en) Resource efficient software tracing for problem diagnosis
WO2011084535A2 (en) Establishing a useful debugging state for a multithreaded computer program
TWI684916B (en) Function selection method and server
CN110879781A (en) Program debugging method and device, electronic equipment and computer readable storage medium
CN112181544B (en) Java application running method, system and device and computer readable storage medium
CN111666200A (en) Testing method and terminal for time consumption of cold start of PC software
CN115757138A (en) Method and device for determining script abnormal reason, storage medium and electronic equipment
CN111367796B (en) Application program debugging method and device
US6745213B2 (en) Method and apparatus to facilitate testing of garbage collection implementations
Tsai et al. Low-overhead run-time memory leak detection and recovery
CN110597705B (en) Program debugging method and device capable of repeatedly acquiring test data
CN111880078A (en) Method and equipment for automated instruction testing
CN117742897B (en) Method for realizing automatic repair of vulnerability based on container mirror image
Pastore et al. AVA: supporting debugging with failure interpretations
CN117170987B (en) Monitoring method, system and related equipment of embedded real-time operating system
CN110879783B (en) Program testing method, device, equipment and storage medium
CN113704088A (en) Process tracing method, process tracing system and related device
JP6668808B2 (en) Untested portion detection device, untested portion detection method, and program

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant