Home > Back-end >  Of new questions - javaagent: parameters
Of new questions - javaagent: parameters

Time:04-07

Parameters - javaagent: how can make a jar package of a certain class files in the
 private static Boolean in_dev_mode=false; 

To assign a value to true!

O dalao solutions

CodePudding user response:

Write an Agent class, realize premain method, if you say the class is ray Class1,
 import ray. Class1; 
Public class Agent1 {
Public static void premain (String agentArgs) {
If (agentArgs. Equals (" t "))
Class1. In_dev_mode=true;
Else if (agentArgs equals (" f "))
Class1. In_dev_mode=false;
}
}

Compile the Agent class
 javac - cp Class1. Jar Agent1. Java 

Write the MANIFEST. MF file
 Premain - Class: Agent1 

Packaging
 jar of CMF MANIFEST. MF Agent1. Jar Agent1. Class 

The
 Java - javaagent: Agent1. Jar=t - jar Class1. Jar 

CodePudding user response:

reference 1st floor rayw0ng response:
write an Agent class, realize premain method, if you say the class is ray Class1,
 import ray. Class1; 
Public class Agent1 {
Public static void premain (String agentArgs) {
If (agentArgs. Equals (" t "))
Class1. In_dev_mode=true;
Else if (agentArgs equals (" f "))
Class1. In_dev_mode=false;
}
}

Compile the Agent class
 javac - cp Class1. Jar Agent1. Java 

Write the MANIFEST. MF file
 Premain - Class: Agent1 

Packaging
 jar of CMF MANIFEST. MF Agent1. Jar Agent1. Class 

The
 Java - javaagent: Agent1. Jar=t - jar Class1. Jar 

Thank?? , already can write
  • Related