Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a Java desktop aplication to manage iptables and i want to execute iptables commands via Java, this is what i am doing:

i execute from terminal gksu "iptables -L" and it worked but when i try to execute it from Java runtime ( exec.("gksu \"iptables -L\" ") ) i keep getting this output:

GKsu version 2.0.2

Usage: gksu [-u ] [options]

--debug, -d

Print information on the screen that might be

useful for diagnosing and/or solving problems.

--user , -u

Call <command> as the specified user.

--disable-grab, -g

Disable the "locking" of the keyboard, mouse,

and focus done by the program when asking for


--prompt, -P

Ask the user if they want to have their keyboard

and mouse grabbed before doing so.

--preserve-env, -k

Preserve the current environments, does not set $HOME

nor $PATH, for example.

--login, -l

Make this a login shell. Beware this may cause

problems with the Xauthority magic. Run xhost

to allow the target user to open windows on your


--description , -D

Provide a descriptive name for the command to

be used in the default message, making it nicer.

You can also provide the absolute path for a

.desktop file. The Name key for will be used in

this case.

--message , -m

Replace the standard message shown to ask for

password for the argument passed to the option.

Only use this if --description does not suffice.

--print-pass, -p

Ask gksu to print the password to stdout, just

like ssh-askpass. Useful to use in scripts with

programs that accept receiving the password on


--sudo-mode, -S

Make GKSu use sudo instead of su, as if it had been

run as "gksudo".

--su-mode, -w

Make GKSu use su, instead of using libgksu's


I hope someone can help me :D plox :P

share|improve this question

You are not doing it right. Make a string array. The first element will be the command name, and the following elements will be arguments.[])

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.