Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3875218
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:14:29+00:00 2026-05-19T22:14:29+00:00

I’m using a daemon-script which is monitoring a remote server. When the remote server

  • 0

I’m using a daemon-script which is monitoring a remote server. When the remote server is up, i want that Netbeans automatically connects it’s Debugger to the remote Server.

Is it possible to control this behavior from commandline?
To type Something like

netbeans --attach-debugger 192.168.178.34:9009

inside a terminal to do that? Or what other ways do i have to get access to Netbeans-internal stuff? (until now, i was just a “user” of Netbeans so i don’t know the internals and how to access them very well)

Or will i have to write a Netbeans Plugin to do that? If yes, can you give me a good starting point to add that functionality?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T22:14:30+00:00Added an answer on May 19, 2026 at 10:14 pm

    Ok since there is no option to attach the Debugger from commandline, i wrote a Netbeans Plugin with the help of this blog entry and this thread from the NB-mailinglist. Now i’m able to call my plugin actions from the Commandline.

    So build a simple NetBeans Module, which contains 2 important classes.
    This is the class which gets the commandline parameters and forwards them to my Action:

    import java.awt.event.ActionEvent;
    import java.util.Collections;
    import java.util.Map;
    import java.util.Set;
    import java.util.logging.Logger;
    import javax.swing.Action;
    import org.netbeans.api.sendopts.CommandException;
    import org.netbeans.spi.sendopts.Env;
    import org.netbeans.spi.sendopts.OptionProcessor;
    import org.netbeans.spi.sendopts.Option;
    import org.openide.ErrorManager;
    import org.openide.cookies.InstanceCookie;
    import org.openide.filesystems.FileObject;
    import org.openide.filesystems.FileUtil;
    import org.openide.loaders.DataObject;
    import org.openide.util.lookup.ServiceProvider;
    import org.openide.windows.WindowManager;
    
    @ServiceProvider(service = OptionProcessor.class)
    public class TriggerActionCommandLine extends OptionProcessor {
    
        //Here we specify "runAction" as the new key in the command,
        //but it could be any other string you like, of course:
        private static Option action = Option.requiredArgument(Option.NO_SHORT_NAME, "debug");
    
        private static final Logger logger = Logger.getLogger(AttachDebugger.class.getName());
    
        @Override
        public Set<org.netbeans.spi.sendopts.Option> getOptions() {
            return Collections.singleton(action);
        }
    
        @Override
        protected void process(Env env, Map<Option, String[]> values) throws CommandException {
            final String[] args = (String[]) values.get(action);
            if (args.length > 0) {
                //Set the value to be the first argument from the command line,
                //i.e., this is "GreetAction", for example:
                final String ip = args[0];
                //Wait until the UI is constructed,
                //otherwise you will fail to retrieve your action:
                WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
                    @Override
                    public void run() {
                        //Then find & perform the action: 
                        Action a = findAction(AttachDebugger.ACTION_NAME);
                        // forward IP address to Action
                        ActionEvent e = new ActionEvent(this, 1, ip);
                        a.actionPerformed(e);
                    }
                });
            }
        }
    
        public Action findAction(String actionName) {
            FileObject myActionsFolder = FileUtil.getConfigFile("Actions/PSFActions");
            FileObject[] myActionsFolderKids = myActionsFolder.getChildren();
            for (FileObject fileObject : myActionsFolderKids) {
                logger.info(fileObject.getName());
                //Probably want to make this more robust,
                //but the point is that here we find a particular Action:
                if (fileObject.getName().contains(actionName)) {
                    try {
                        DataObject dob = DataObject.find(fileObject);
                        InstanceCookie ic = dob.getLookup().lookup(InstanceCookie.class);
                        if (ic != null) {
                            Object instance = ic.instanceCreate();
                            if (instance instanceof Action) {
                                Action a = (Action) instance;
                                return a;
                            }
                        }
                    } catch (Exception e) {
                        ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
                        return null;
                    }
                }
            }
            return null;
        }
    
    }
    

    This is my Plugin Action which attaches the Debugger to the given remote address:

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import org.netbeans.api.debugger.jpda.DebuggerStartException;
    import org.netbeans.api.debugger.jpda.JPDADebugger;
    import org.openide.DialogDisplayer;
    import org.openide.NotifyDescriptor;
    import org.openide.awt.ActionRegistration;
    import org.openide.awt.ActionReference;
    import org.openide.awt.ActionReferences;
    import org.openide.awt.ActionID;
    import org.python.util.PythonInterpreter;
    
    @ActionID(category = "PSFActions", id = "de.mackaz.AttachDebugger")
    @ActionRegistration(displayName = "#CTL_AttachDebuggerAction")
    @ActionReferences({
        @ActionReference(path = "Menu/Tools", position = 1800, separatorBefore = 1750, separatorAfter = 1850)
    })
    public final class AttachDebugger implements ActionListener {
    
        private static final Logger logger = Logger.getLogger(AttachDebugger.class.getName());
    
        public static final String ACTION_NAME="AttachDebugger";
    
        @Override
        public void actionPerformed(ActionEvent e) {
            String ip;
            if (!e.getActionCommand().contains("Attach Debugger")) {
                ip = e.getActionCommand();
            } else {
                ip = lookupIP();
            }
            try {
                logger.log(Level.INFO, "Attaching Debugger to IP {0}", ip);
                JPDADebugger.attach(
                        ip,
                        9009,
                        new Object[]{null});
            } catch (DebuggerStartException ex) {
                int msgType = NotifyDescriptor.ERROR_MESSAGE;
                String msg = "Failed to connect debugger to remote IP " + ip;
                NotifyDescriptor errorDescriptor = new NotifyDescriptor.Message(msg, msgType);
                DialogDisplayer.getDefault().notify(errorDescriptor);
            }
        }
    }
    

    Now i can attach the Netbeans debugger to a specific address by calling netbeans/bin/netbeans --debug 192.168.178.79

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.