java-native-access/jna · error · com.sun.jna.platform.win32.COM.tlb.imp.TlbParameterNotFoundException
Commandline parameter not found: <key>
Error message
Commandline parameter not found: <key>
What it means
TlbCmdlineArgs.getRequiredParam retrieves a command-line parameter and throws TlbParameterNotFoundException when no value exists for the given key. It enforces that mandatory options were supplied to the COM type-library importer. The message names the missing key so you can see which option is absent.
Source
Thrown at contrib/platform/src/com/sun/jna/platform/win32/COM/tlb/imp/TlbCmdlineArgs.java:47
private static final long serialVersionUID = 1L;
public TlbCmdlineArgs(String[] args) {
this.readCmdArgs(args);
}
public int getIntParam(String key) {
String param = this.getRequiredParam(key);
return Integer.parseInt(param);
}
public String getParam(String key) {
return this.get(key);
}
public String getRequiredParam(String key) {
String param = this.getParam(key);
if (param == null)
throw new TlbParameterNotFoundException(
"Commandline parameter not found: " + key);
return param;
}
private void readCmdArgs(String[] args) {
if (args.length < 2)
this.showCmdHelp();
for (int i = 0; i < args.length;) {
String cmdName = args[i];
String cmdValue = args[i+1];
if (cmdName.startsWith("-") && !cmdValue.startsWith("-")) {
this.put(cmdName.substring(1), cmdValue);
i+=2;
}else {
this.showCmdHelp();
break;View on GitHub (pinned to d036ad9781)
Solutions
- Add the missing parameter to the com2java command line (check the key name shown in the message)
- Verify argument syntax expected by TlbCmdlineArgs (key=value pairs)
- Wrap the generator invocation in a script that validates required args before running
- If the param is genuinely optional in your flow, use getParam instead of getRequiredParam
Example fix
// before java -jar com2java.jar -output C:\out mylib.tlb // after java -jar com2java.jar -tlb mylib.tlb -output C:\out -package com.mylib.jna
Defensive patterns
Strategy: validation
Validate before calling
Map<String,String> args = parse(argsArray);
for (String required : List.of("tlb", "output")) {
if (!args.containsKey(required)) throw new IllegalArgumentException("missing arg: " + required);
} Try / catch
try { String tlb = cmdArgs.getRequiredParam("tlb"); } catch (TlbParameterNotFoundException e) { /* print usage with e.getMessage() */ } Prevention
- Keep the com2java invocation in a reviewed script with all required args
- Validate command-line args before calling the generator
- Print usage on missing keys
When it happens
Trigger: Calling TlbCmdlineArgs.param/getRequiredParam (directly or via TlbImp) for a key such as 'tlb' or 'output' that was never passed on the command line, or passed with wrong spelling/missing '=' separator.
Common situations: Invoking com2java from an Ant/CI script with an incomplete argument list; upgrading JNA's contrib tool and a previously optional parameter becoming required; forgetting quoting so one of two arguments is lost.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Output directory NOT sucessfully created to: <comRootDir>
- remove
- advise: Interface must define a value for either iid via the
- ComInterface must define a value for iid
- Class type <paramTypes[i].getName()> not mapped to primitive
AI-assisted analysis of java-native-access/jna@d036ad9781 (2026-09-12).
Data as JSON: /api/errors/6dd5eb263b965dcf.
Report an issue: GitHub.