Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

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"  
    then  
       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"
          exit
       end if
 end if  
share|improve this answer
1  
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

/usr/bin/software-center

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

 
discard

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.