Giter Site home page Giter Site logo

simple-java-agent's Introduction

Simple-Java-Agent

Hi, This is very simple Java Agent to understand what and how to write a small agent for beginners.

What is the java agent!

JVM TI is a tool used to inspect the state and to control the execution of applications running in JVM.Its provides a VM interface for the full breadth of tools that need access to VM state including profiling, debugging, monitoring and etc… JVM TI is a two way interface. Client of JVM TI is called agent,can be notified of interesting events.It can query and control the application through many functions.

Actually java agent is a program that can be execute separately without interfering other process .We can use Agent for track the methods in a program without changing it. Normally we can run it in two phases,

1.OnLoad phase

2.Live phase

Also we can shutdown the agent by UnLoading libraries or unloaded by the termination of the VM whether through normal termination or VM failure, including start-up failure.But this will not work for uncontrolled shutdown. JVM specify different , separate environments for each agent. And they are independent from others and changes of one not affect to another. We can use agent for different purpose. Agent can Monitor threads,suspend and resume them.Also monitor classes ,change them and do many other functions. Agents can inspect and modify the shared state of the VM , they also share the native environment in which they execute.Also an agent can be fail other agents. But JVM TI implementations are not capable of preventing destructive interactions between agents.

You can use this link to see more in detail. [ https://docs.oracle.com/javase/8/docs/platform/jvmti/jvmti.html ]

How to run!

  1. Open terminal in the folder( that contain all 3 files).

2.use this codes in terminal(console)

i. javac  *.java 
(This will create class files)

ii. jar cvfm Agent.jar manifest.mf *.class
(This will create Agent.jar file )

iii. java  -javaagent:MyJar.jar SampleClass-
This code will execute the Agent.jar file and give the output)

Output!

	Simple Agent
	
	This is Main Method

simple-java-agent's People

Contributors

shehanperera avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.