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.

How to create command line application c++ or Java? I have some commands which I would like to convert into an application.
How to do it in eclipse?
Just for example consider:

sudo apt-get upgrade xyz

I want to get it into ubuntu repository. Or I'll create a gui using qt with c++ or java plugin.

share|improve this question

closed as unclear what you're asking by Gilles, Thomas W., Basharat Sialvi, Mik, jokerdino Aug 18 '13 at 5:18

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
What do you mean by an "application"? If you have a command, it's already an application. Do you mean to ask how you package it up for distribution? How to get it into the Ubuntu repos? –  Kevin Aug 17 '13 at 14:52
3  
I think he is trying to make a package that can be added to a PPA and updated/modified and upgraded via apt-get. But in it's current form this question is too vague to answer... –  Thomas W. Aug 17 '13 at 14:59
    
Are you looking for ways to creating a command line application? Please be more specific about exactly what you want so we can satisfactorily answer your question. –  jokerdino Aug 18 '13 at 5:16
    
This appears to be two questions: one asking how to make an application that runs commands, and another asking what the different options are for making programs available to Ubuntu users. If that is the case, I recommend removing the second question (by editing), changing the title to reflect just the first one, searching for answers to the second question, and posting the second question as a separate question if you don't find answers. –  Eliah Kagan Aug 18 '13 at 7:50

2 Answers 2

up vote 1 down vote accepted

In C++ you can use int system (const char* command); function.

Example:

/* system example : DIR */
#include <stdio.h>      /* printf */
#include <stdlib.h>     /* system, NULL, EXIT_FAILURE */

int main ()
{
  int i;
  printf ("Checking if processor is available...");
  if (system(NULL)) puts ("Ok");
    else exit (EXIT_FAILURE);
  printf ("Executing command DIR...\n");
  i=system ("dir");
  printf ("The value returned was: %d.\n",i);
  return 0;
}

Source: http://www.cplusplus.com/reference/cstdlib/system/

In your case you can use:

system ("sudo apt-get upgrade");

In Java is slightly more complicated. You can use exec method of the Runtime class in java.lang. See http://www.linuxforums.org/forum/programming-scripting/65117-c-c-system-function-analog-java.html

share|improve this answer

If you want to be able to use the apt-get command with your programm, it needs to be in a apt repository, whose url must be in the /etc/apt/sources.list file. You can learn how to set up your own apt repository here.

share|improve this answer

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