Supercharge Your Innovation With Domain-Expert AI Agents!

Java program execution method and device

A technology of program execution and program, which is applied in the field of Java program execution method and device, can solve problems such as occupation and multiple system resources, and achieve the effect of shortening time

Active Publication Date: 2015-05-06
浙江杭海新城控股集团有限公司
View PDF3 Cites 4 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0006] In order to solve the problem in the prior art that an independent process is created every time a Powershell script is executed by a Java program, causing excessive system resource occupation, an embodiment of the present invention provides a method and device for executing a Java program

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • Java program execution method and device
  • Java program execution method and device
  • Java program execution method and device

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0061] The embodiment of the present invention provides a Java program execution method, see figure 1 , the method includes:

[0062] Step 101: Load a DLL (Dynamic Link Library, dynamic link library) file, where the DLL file includes: the implementation of the first Native method for creating the Powershell script execution environment pool, and the second Native method for executing the Powershell script realization.

[0063] This DLL file is used to execute Powershell scripts in Java programs.

[0064] Step 102: Invoke the first Native method to create a Powershell script execution environment pool, where the Powershell script execution environment pool includes multiple Powershell script execution environments.

[0065] Step 103: Invoke the second Native method to execute the Powershell script in the Java program in the Powershell script execution environment.

[0066] Step 104: Return the execution result of the Powershell script.

[0067] In the embodiment of the pres...

Embodiment 2

[0069] The embodiment of the present invention provides a Java program execution method, see figure 2 , the method includes:

[0070] Step 201: Obtain a Java file, where the Java file includes a declaration of the name of the DLL to be called, and declarations of the first Native method, the second Native method, and the third Native method.

[0071] Java files are compiled from Java code. The first Native method is used to create a Powershell script execution environment pool, the pool includes several script execution environments, and the number of script execution environments can be specified in the code. The third Native method is used to preload the Powershell script dependency class library in the above script execution environment for use during script execution. The second Native method is used to obtain an idle script execution environment from the script execution environment pool when the Powershell script needs to be executed, and then execute the Powershell s...

Embodiment 3

[0095] This embodiment of the present invention provides a Java program execution method. The difference between this embodiment and the second embodiment is that JNI4NET is used to implement compilation. See image 3 , the method includes:

[0096] Step 301: Acquire and compile C# code to generate a CS file, where the C# code includes the implementation of the first Native method, the second Native method and the third Native method.

[0097] The first Native method is used to create a Powershell script execution environment pool, the pool includes several script execution environments, and the number of script execution environments can be specified in the code. The third Native method is used to preload the Powershell script dependency class library in the above script execution environment for use during script execution. The second Native method is used to obtain an idle script execution environment from the script execution environment pool when the Powershell script ne...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a Java program execution method and device, and belongs to the field of the computer. The method comprises the following steps: loading a dynamic link library file, wherein the dynamic link library file comprises the implement of a first local method used for creating a Powershell script execution environment pool and the implementation of a second local method used for executing a Powershell script; calling the first local method, and creating the Powershell script execution environment pool, wherein the Powershell script execution environment pool comprises a plurality of Powershell script execution environments; calling the second local method, executing the Powershell scripts in a Java program in the Powershell script execution environments; and returning a Powershell script execution result. Expenditures generated when the Powershell script in the Java program is executed are lowered.

Description

technical field [0001] The present invention relates to the field of computers, in particular to a Java program execution method and device. Background technique [0002] Java is an object-oriented programming language that can write cross-platform application software. It is a general term for the Java programming language and the Java platform introduced by Sun. Java has excellent versatility, efficiency, platform portability and security, and is widely used in various fields. [0003] When a Java program runs on the Windows platform, it is often necessary to call Windows Powershell scripts to achieve corresponding business purposes. For Java applications running on the Windows platform, it can only be achieved through the JavalangRuntime exec(String command) method provided in the Java application programming interface. This method will restart a Java application process outside the currently running process. An independent Powershell script process, thereby executing t...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Applications(China)
IPC IPC(8): G06F9/45
Inventor 石林灵
Owner 浙江杭海新城控股集团有限公司
Features
  • R&D
  • Intellectual Property
  • Life Sciences
  • Materials
  • Tech Scout
Why Patsnap Eureka
  • Unparalleled Data Quality
  • Higher Quality Content
  • 60% Fewer Hallucinations
Social media
Patsnap Eureka Blog
Learn More