I'm working on an SNMP Manager in Java.
I have multiple MIB files that I want to parse as objects, so I can use their data within my code.

In order to do that, I need a good MIB file parser that can convert the data to structures, and provide comfortable API (in Java of course) so I could use them.

Does anyone know one? (preferably open source)

  • Upvote, but curious as to why you are reinventing the wheel when there are free (for commercial use) MIB viewers out there?
    – Mawg
    Commented Jan 10, 2019 at 9:26
  • 1
    @Mawg I want to use the data within my code, so I want to load it as an object that will be easily accessible from the code. Commented Jan 10, 2019 at 9:46
  • Thanks for the explanation. That's not really clear from your question. Maybe you ought to edit it?
    – Mawg
    Commented Jan 10, 2019 at 10:33
  • 1
    @Mawg Thanks for the remark, I'll edit it. Commented Jan 10, 2019 at 10:49

1 Answer 1


I am unsure if this will help you. It seems to be an SNMP library for .NET (which I do not use).

Alternatively: I long ago gave up handcrafting parsers and moved to Lex/Yacc (later Flex/Bison).

Then I discovered Antlr which allows you to write your own grammar and syntax rules and generate source code in many languages to parse those rules.

You appear to be lucky in that someone has already created a free SNMP grammar parser – see https://www.antlr3.org/grammar/list.html

Either of those should probably help you, but I want to wax lyrical here on Antlr, which is an incredible timesaver.

In addition to letting you define your grammar in a visual way, with a nice GUI (workbench plus plug-ins for Intellij, NetBeans, Eclipse, Visual Studio Code, and jEdit.), it allows you to visualize your grammar, as a graphical parse tree, and to visually debug (tutorial here), stepping through the element which you are parsing, watching it pass through your parser and easily spotting errors in your grammar.

enter image description here

See the mega tutorial for more.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.