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

My Java application needs this library libswt-webkit-gtk-3-jni to run successfully. So if the user doesn't have this library installed, I want Ubuntu Software Center to be launched and tell the user "you should have this library".

Is that possible?

share|improve this question

Yes, it is, but don't use Ubuntu center to do that. In pseudo code I would do something like:

 if result_of("dpkg --get-selections libswt-webkit-gtk-3-jni") != "install"  
       ask user "Should the necessary libraries be installed?"
                "This requires administrator privileges"
       if yes
          gksudo apt-get install libswt-webkit-gtk-3-jni -y  
       if no
          tell user "Necessary libraries are missing"
       end if
 end if  
share|improve this answer
I agree! However, I would add "gksudo" to call the apt-get, and only after the user has been informed. – January Oct 8 '12 at 10:51
Thanks @January for the completion. :) – Frantique Oct 8 '12 at 11:10

Sure, the command to launch the software center is


You can even specify a package name on the command line:

/usr/bin/software-center libswt-webkit-gtk-3-jni
share|improve this answer
So would it be: Process process = new ProcessBuilder("xterm", "-e", "/usr/bin/software-center").start();? (not tested) – Evandro Silva Oct 8 '12 at 10:43
I think (without knowing Java!) that it would be Process process = new ProcessBuilder("/usr/bin/software-center", "libswt-webkit-gtk-3-jni").start();. No need to start an xterm, when you can start the software center directly. Can you try it for me? – January Oct 8 '12 at 10:49
actually, you're right ;) – Evandro Silva Oct 8 '12 at 10:52
@EvandroSilva Please consider the apt-get alternative presented by Frantique above. – January Oct 8 '12 at 10:54

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.