You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JMX配置启动报错:无法找到或加载主类-Dcom.sun.management.jmxremote.port=8090

Fixing the "Could not find or load main class" Error for JMX Setup

Hey there, let's break down what's going wrong with your JMX startup command and get it working so you can monitor your beans properly.

Why You're Seeing This Error

That error message means the JVM is mistakenly treating your JMX -D parameter as the name of the main class it should run—instead of recognizing it as a configuration flag. There are two key issues with your command:

  1. Trailing spaces after backslashes: When you use \ to split a command across lines in Linux, the backslash needs to be the very last character on the line. If there's a space after it, the shell won't properly combine the lines, so the next -D parameter gets treated as a standalone input (aka the main class).
  2. Missing main class/jar: Your command doesn't specify which Java class or jar file you actually want to run. The JVM needs this to know what application to attach the JMX config to.

Corrected Command

Here's the fixed version of your command—note the clean line breaks (no spaces after \) and the addition of your main class or jar at the end:

# For running a specific main class
java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=9010 \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
com.your.package.YourMainClass

# OR for running a jar file
java -Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.port=9010 \
-Dcom.sun.management.jmxremote.local.only=false \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-jar your-application.jar

Quick Tips to Avoid Future Issues

  • Double-check your line breaks: No spaces after \—this is a super common gotcha in shell commands.
  • If you're connecting from a remote machine, make sure your Linux firewall allows traffic on port 9010 (use ufw allow 9010 if you're using ufw, for example).
  • Once your app starts with this corrected command, fire up jconsole again and connect to your-server-ip:9010—you should now see your JMX beans listed.

内容的提问来源于stack exchange,提问作者Varun Kumar Rai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 04:05:31