Read MIB File Programmatically (via Java Code)


In our company we are using AgenPro to compile and build Java Files from .MIB files.

I am new on the project and I can see we are using “com.oosnmp.agenpro” and in POM we have also set ours license Keys as well. It is my guess that our project uses Apache Velocity to build the Java files from the MIB files.

Up till now I have seen following link: and some other links on the subject but still I am struggling with get my head around the concept of doing it programmatically in Java.

So What I want:

Objective 1: Some tutorials or demo code that shows how to load a (.mib) file and convert into its equivalent (.java) and read below information from it (I am open to use velocity as well)

		debug(4) }
MAX-ACCESS read-write
STATUS  current
	"Compile Event Log Level"
DEFVAL { error }
::= { compEntry 10 }

Objective 2: So, In my java Program I should be able to read “MAX-ACCESS”, “DESCRIPTION” property and should also be able to retrieve INTEGER ENUM of critical, error, warning and so on and so forth.

So Sir can you please guide me to some programing code samples so that I can achieve point 1 and 2.

Once again I am so thankful for your time and consideration.

Maybe there is a misunderstanding about the use cases of the tool.

SNMP SMI MIB information can be used in general at two points in application development:

  1. Compile-time
  2. Run-time

AgenPro is for compile-time usage. Compile-time usage is generally preferred because it provides best performance and as better testable because there are no user-dependent „surprises“ during run-time.

To use MIB information at runtime, use SNMP4J-SMI-PRO. It loads MIB information into your SNMP4J enabled application(s) and provides full access to all MIB details. That is different to AgenPro, where Java or c++ code is generated and the MIB information is already translated to program code.

Hope this helps.

Best regards,

Hi Frank,

Thanks for the response, So I should be using AgenPro for compile-time usage.

But If want to do it programmatically(java) how can I do it?

So that I should be able to read above MIB information via my code.

I am sorry If I am repeating myself again and again much to your annoyance, but just want to understand its concepts, if you can point me to some tutorials and documentation so that I can achieve my objective

much thanks in advance for bearing with me :slightly_frowning_face:


You can use SNMP4J-SMI-PRO as shown here
The API documentation:

Hi Frank,

I am using a example from the link: How to use SNMP4J-SMI with SNMP4J? - SNMP4J - AGENTPP,

at this line: SmiManager smiManager = new SmiManager("our_key", file);
and since I already have a compiled MIB then I’ll use this following line
smiManager.loadModule( "SNMP-VIEW-BASED-ACM-MIB" );

But, unfortunately for now, I am getting below error

*Exception in thread "main" java.lang.NoClassDefFoundError: com/objectspace/jgl/BinaryPredicate at com.snmp4j.smi.SmiManager.<init>(SourceFile:202) at com.snmp4j.smi.SmiManager.<init>(SourceFile:246)*

I believe I need to use this import statement. import com.objectspace.jgl.;*

Please correct me if I am wrong, and also from where I can download the binaries for it? I am searching for it but can’t seem to find maven repo for it. Or am I doing something wrong here?

best regards,


You need to use the
and not the plain API to get all dependent libraries as well. That’s all :slight_smile:

Best regards,

okay when I use

import com.snmp4j.smi.*;

the error from SmiManager goes away

but still after updating my POM to use -jar-with-dependencies.jar I am still getting same error

Hi Sir,

I am still doing something wrong and can’t seem to figure it out.

the files get downloaded to my maven repository in following folder structure


and following jar are there

  1. snmp4j-smi-pro-1.9.7.jar
  2. snmp4j-smi-pro-1.9.7-jar-with-dependencies.jar

but when I do import org.snmp4j.smi.*; in my code I get red squiggly lines (denoting error) on line

SmiManager smiManager = new SmiManager(“key”, file);

and I have updated my pom with following plugin


but my error is still the same

I can’t seem to get where the problem is, and what I am doing wrong?

I hope you can help me

much regards

I have updated the FAQ to include an important detail in the dependency declaration of the pom.xml.
You need to provide the classifier to use the JAR with the dependencies included:


Hope this helps finally :slight_smile:

Thanks You frank, Its so nice of you to help me through this :+1: