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 484645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:19:15+00:00 2026-05-13T01:19:15+00:00

I am working on a project in netbeans that requires the running project to

  • 0

I am working on a project in netbeans that requires the running project to have root privileges.

I would like it so that each time I push “Run Project” (F6) my project is run as root, so with the equivalent of “gksudo javac Main”, as it is has a GUI.

One option is to start netbeans with root privileges, easily done by editing the shortcut to “gksudo netbeans”. But as I have multiple projects in netbeans this has meant that for each project I must run netbeans with root privileges, this is not what I want.

Another option, of course, is to simply run my project from the shell, but this is not ideal either.

I think this is possible by altering this projects build.xml file but am having trouble figuring out how.

After some research it would be seem that this is rather an Apache Ant question, I have access to build.xml which I can modify so I need to know how to get Ant to run my project with sudo/gksudo. However, I can’t figure out how to do this or if it is possible.

  • 1 1 Answer
  • 2 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-13T01:19:16+00:00Added an answer on May 13, 2026 at 1:19 am

    Assuming this is a “Java SE” project (as opposed to, say, a web app or a Ruby program). First, turn off Compile on Save under Compiling in project properties.

    Second, add to build.xml:

    <target name="-init-macrodef-java">
        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
            <attribute default="${main.class}" name="classname"/>
            <attribute default="${run.classpath}" name="classpath"/>
            <element name="customize" optional="true"/>
            <sequential>
                <exec executable="gksudo" failonerror="true">
                    <arg value="--"/>
                    <arg value="java"/>
                    <arg value="-classpath"/>
                    <arg path="@{classpath}"/>
                    <arg line="${run.jvmargs}"/>
                    <arg value="@{classname}"/>
                </exec>
            </sequential>
        </macrodef>
    </target>
    

    There are other things you can fine-tune but this should be enough to get you started.

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

Sidebar

Related Questions

I am working on a Java project using Netbeans for the first time. I
I am working a project that does not have a trunk / branches /
I'm working on a project that uses NetBeans to generate the ANT build files.
I'm working on a project that needs Jasper reporting, I have used the code
I have a Java project that I write in Netbeans on Glassfish server. It
I am working on a project where I have a class called HGraphic that
I'm currently working on a project using netbeans 6.9 and grails 1.3. I'm trying
I'm working for a Swing Project and the technologies used are netbeans with Toplink
I working on project and have problem with threading and update of UI. I
I'm currently working on project with Haskell, and have found myself some trouble. I'm

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.