Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

read list of installed softwares in linux using java program

 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to write a java program which runs on a linux machine,and this java program should give the list of installed rpms on that machine. I am not sure what is to be done. I also gone through the site which tells how to "http://www.codeproject.com/KB/files/CoolCode.aspx" read the list of sofware's installed on windows. I want something similar for my linux machine.

Any information on this would be great...
 
Saloon Keeper
Posts: 22256
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be hard to do that in Java, because RPM's are not merely OS-specific, they're specific to only certain Linux distros. Debian and Ubuntu, for example, use ".deb" packages, instead.

However, it's a trivial task to get the list of installed RPM's. In many releases, it's kept in /var/log/rpmpkgs, although interestingly, I see that Fedora 14 isn't one of them.

For systems where that file isn't available, you can simply query RPM itself with the "rpm -qa" command and read the stdout stream. If the basic package name isn't sufficient and you want refinements like the actual release, there are additional options. This is the one that builds /var/log/rpmpkgs:


The actual cron job sorts the results using the "sort" utility.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim,

So i believe what i should do is run something like this below?



Please correct me if iam wrong
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really see the purpose of using Java for doing this, since after all you end up just execing a process from Java. What's the requirement for using Java?
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this java program runs on a linux machine.It reads all the rpms installed on that linux machine and displays to the user..hope you got it now..
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the key:

Maan Suraj wrote:displays to the user


And you never said what kind of display!
If displaying on the command line, then writing a Java app is useless - use Tim's one-liner instead.
If displaying in a web browser or in a GUI, then Java will be helpful in formatting the display, though you would still use Tim's one-liner to gather the data.
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on usage, I would probably recommend using WebMin.
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone
@Peter: Yes it is to display in thr browser.

Ya Tim's one liner helped. Also below code works fine



thanks :-)
 
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic