How do I get started with Mibble MIB Parser in Java?

Updated

Mibble is an open-source Java library that reads SNMP MIB files written in ASN.1 syntax and exposes their contents — OIDs, types, descriptions, comments, and the original MIB source text — through a Java API. To get started, download the library, add it to your Java project, and call the parser from your code; the same distribution also ships a graphical MIB browser and command-line apps for formatting and validation. This applies if you need to read MIB files in Java. If you need to send or receive SNMP traffic, Mibble alone is not enough (see the note on SNMP below).

What you need before you start

  • A Java development environment (Mibble is a Java library).
  • The Mibble distribution, obtained from the Download section of the site or from the project's GitHub repository.
  • One or more MIB files in ASN.1 syntax to parse. The distribution includes standard IANA and IETF MIBs, so you can test against those before pointing the parser at your own files.
  • A clear idea of which of the two licensing paths applies to your project, since that determines whether you can redistribute Mibble inside your product (see the licensing section).

Step 1: Get the library

Mibble is distributed through the Download section of mibble.org, and the full source code is available on GitHub. The distribution is more than just the parser library — it also bundles:

  • A Java library for parsing SNMP MIBs.
  • All standard IANA and IETF MIBs.
  • A graphical MIB browser with a simple SNMP manager.
  • Command-line apps for MIB formatting and validation.

If you only need the parsing API, you can ignore the browser and command-line tools; they are useful mainly for inspecting and sanity-checking MIB files before you write code against them.

Step 2: Parse a MIB and read its contents

The core workflow is: load a MIB file, let Mibble parse the ASN.1 syntax, then query the resulting object model. According to the project description, the API gives you access to:

  • OIDs — the object identifiers defined in the MIB.
  • Types — the data types associated with those objects.
  • Descriptions — the textual description fields.
  • Comments — comments contained in the MIB.
  • Original MIB source text — the raw text the MIB was parsed from.

The exact class and method names are covered in the Docs section of the site, so treat that as the authoritative reference for the current API rather than relying on remembered signatures. A practical approach when starting out:

  1. Parse one of the bundled standard MIBs first, so you know the input is valid.
  2. Walk the parsed structure and print OIDs and types to confirm you are reading what you expect.
  3. Then point the parser at your own MIB files and repeat.

Expected result: a populated in-memory model of the MIB that you can traverse programmatically instead of parsing text yourself.

Step 3: Use the included tools for validation

Before debugging your own code, check whether the problem is the MIB file rather than your parser usage. The bundled command-line apps handle MIB formatting and validation, and the graphical MIB browser lets you inspect a MIB interactively. If a MIB fails to parse in your application, running it through these tools first will usually tell you whether the file itself is malformed.

Licensing: which path applies to you

Mibble is dual-licensed under GNU GPL and a commercial license, and the full source code is provided under both.

GNU GPL Commercial
Cost Permits free usage Purchased from the Mibble Store
Redistribution Redistribution of Mibble or derived code is restricted to the same license Permits inclusion in almost any software product
Best suited to Projects that can comply with GPL terms Products that cannot ship under GPL

If you are building something you intend to distribute under a non-GPL license, the GPL path will not work for you and the commercial license is the relevant one. The site points to a GNU GPL license FAQ and a commercial license FAQ for the details, and licenses are purchased from the Mibble Store.

Important limitation: Mibble is not an SNMP stack or MIB compiler

Mibble is explicitly not an SNMP stack and not a MIB compiler. It provides the functionality for reading SNMP MIB files — that is, it is an SMI parser. Two consequences follow:

  • If you need both MIB parsing and SNMP manager functionality, use Mibble together with either SNMP4J or Westhawk's SNMP stack.
  • If you want to build a MIB compiler, Mibble can serve as the basis, because it exposes all the readable information from the MIB files.

For background on the protocol itself, the site points to RFC 3411, An Architecture for Describing SNMP Management Frameworks.

Common snags

  • Expecting SNMP traffic from Mibble. It parses MIBs; pair it with an SNMP stack for manager functionality.
  • Assuming the GPL covers commercial redistribution. It does not permit redistribution under a different license — that is what the commercial license is for.
  • Debugging your code before validating the MIB. Run the file through the bundled validation and browsing tools first.
  • Guessing at API signatures. Use the Docs section for the current API rather than working from memory.