Running linux applications in Java

I'm doing a project for an application to do wireless mapping, using existing open-source programs (like Kismet and TCPdump).
My problem is that I need to launch linux applications in super user mode from my java program, but I don't know how! I was using Runtime.getRuntime.exec() to launch applications (something like this):
Process prsc;
Runtime rt;
public boolean openApp(String app){ //app is a string with the application to open
try{
rt=Runtime.getRuntime();
prsc=rt.exec(app);
} catch(IOException e){
return false;
return true;
and then using prsc.destroy() to kill the open app.
This was working fine with gedit (used for testing) but now I need to open Kismet wich needs to be open with super user permissions. Anyone know how to do this?
Jo�o Guilherme

Use sudo, e.g. sudo -p passwd kismetYou
need to look up the exact syntax, obviously. Have
your Java program ask the user for the password.You will also need to add the user to the 'sudo'ers list.

Similar Messages

  • Unable to run my application using java web start

    i have created one application and use java web start to download the application. all the files are succesfully downloaded but when i try to run the application an expected error occur. this only happen in my machine but not in other machine i'm currently using
    -jsdk1.4.2
    -windows 2000 professional 5.00.2195 service pack 3
    -pentium III 870 Mhz
    -x86-based PC
    -RAM 256 Mhz
    Anyone knows why, plz help me with this puzzle

    Please post the information from the Web Start "Exception" and "Wrapped Exception" tabs when the error occurs (I assume the error was in fact unexpected ;-)
    A blind stab in the dark would be that you don't have write permission to the cache directory on the second machine. Also worth checking that the proxy settings on the second machine are the same as the first (if they are on the same network).

  • How to run Other application from Java

    I want to run other applications such as IE.exe, notepad.exe from Java? How can I run?

    Dear Friend, the following is the code to open IExplorer from Java Program
    class RunTimeTest {
    public static void main(String args[]) {
    try {
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe");
    catch(Exception e) {
    [\code]
    ALL THE BEST
    Shiva                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Help running an application with java

    public void actionPerformed(ActionEvent event)
          if (event.getActionCommand().equals("Application"))
              getContentPane().runApplication(Application);
    }What would replace "runApplication(Application)"?
    Thanks.

    What on earth are you trying to do with that code?
    Do you just want to execute an external application via java, such as with the Runtime.exec() method?
    try {
       Runtime.getRuntime().exec(...);
    } catch ( ... )Something similar to that?

  • Running a Linux application from Java

    Hy,
    I am working at a faculty project and I need your help
    What I want to do is by clicking a button, in a JFrame I want to open an application ,for example Mysql Query browser. I am using FC 6 and Netbeans 5.5
    Can you help me??
    Thanks

    can I open the konsole from java??Yes.
    First you must figure out how to do that from the command line yourself. That has nothing to do with java.
    Note that that how you do that MUST account for the fact that the "command line" is actually a shell. Some commands must be run by running the shell as the actual command and then passing the desired command as an option to the shell (the actual command.)
    Again you can google for examples.

  • Running and application without java

    Hi,
    I have made an application installer (in java) for my project..
    My concern is that how can i run my installer on a machine that doesnt have java installed on it,, possible solution could be to bundle the jre withmy installer and via batch file set the path pointing to my jre..but I dont want the black cmd line window to be appeared..
    By the way install shield and other installers uses their own jre ,, I want to know how do they do that..
    Thanks in advance
    Dexter108

    I very much doubt you can do what you want. How can a Java program run without Java installed ? It is not possible.
    If Install Shield, etc do it somehow as yourself 'Are these programs written in Java or some other language?' I suspect they are written in C++ and so can do what they like as far as being able to install a JRE because they are not dependent on Java being installed.
    You would be better Zipping up all the files you need (including the JRE installer) and using this as the installer. This would at least provide the user with all files required. They can then manually run the JRE installer and once they have done this your app should work.

  • Running an application from java

    Hi all,
    Can someone help with this. It is a calculator application using the unix bc calculator program to evaluate the expression.
    I get no results form this code. The application hangs. Where have I gone wrong.
    public void calculate() {
            try {
                exp.append("\\r\\n");   // add carriage return to the end of the expression
                Process p = Runtime.getRuntime().exec
                        ("bc -qi");
                BufferedWriter output = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                output.write(exp.toString());
                while ((result = input.readLine()) != null) {
                    System.out.println(result);
                input.close();
                p.destroy();
            } catch (Exception err) {
                err.printStackTrace();
        }thanks,
    Sebastian

    Thanks.
    changing to
    exp.append("\n");and flushing the writer stream and closing the stream fixed the problem.
    Why do we have to flush the stream?
    and, why do we have to close the writer before reading? what if I want to continue writting in to the writer?
    thanks again.

  • Not getting application in Java Web Start

    Hello Sir,
    I wanted to run an application using Java Web Start. So, I created a jnlp file and i have mentioned the necessary jar files and the main class file. when I clicked on the jnlp file, the application is running in the Server using Java Web Start and its shortcuts are creates on the desktop and in the startmenu. I am able to run the application by clicking on the shortcut in the server. But I am unable to Download the application in the Java Web Start. It is not showing any Error Messages and the application is not running in the cleint machines.
    The contents of the jnlp file is as follows.
    <?xml version="1.0" encoding="utf-8"?>
    <!-- JNLP File for SimpleClass Demo Application -->
    <jnlp
    spec="1.0+"
    codebase="http://dev01/Dummy/New"
    href="SimpleClass.jnlp">
    <information>
    <title>SimpleClass Demo Application</title>
    <vendor>xxx</vendor>
    <!-- <homepage href="docs/help.html"/> -->
    <description>SimpleClass Demo </description>
    <description kind="short">A demo of Class A and Class B Dependencies in java Web Start.</description>
    <!-- <icon href="images/swingset2.jpg"/> -->
    <!-- <icon kind="splash" href="images/splash.gif"/> -->
    <offline-allowed/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.4.0"/>
    <jar href="ClassLib.jar"/>
    </resources>
    <application-desc main-class="A"/>
    </jnlp>
    So, please Tell me how to solve this problem.
    Thanking you
    R.Venkatesh
    MakeLogic
    www.makelogic.com
    [email protected]

    Here is an example of my JNLP file that works.
    <?xml version="1.0" encoding="utf-8"?>
    <!-- JNLP File for the Passport Application -->
    <jnlp spec="1.0+" codebase="http://application:8080/application/" href="passport.jnlp">
      <information>
        <title>Passport</title>
        <vendor>WIM Consulting</vendor>
        <homepage href="http://www.wim.ca"/>
        <description>application Passport.</description>
        <description kind="short">Passport</description>
        <icon href="WIMicon.gif" width="32" height="32"/>
        <icon href="WIMsplash.jpg" kind="splash"/>
        <offline-allowed/>
      </information>
      <security>
        <all-permissions/>
      </security>
      <resources>
        <j2se version="1.4+"/>
        <jar href="passport.jar"/>
        <jar href="jars/kunststoff.jar"/>
        <jar href="jars/ldapsec.jar"/>
        <jar href="jars/localedata.jar"/>
        <jar href="jars/mysql-connector-java-3.0.6-stable-bin.jar"/>
      </resources>
      <application-desc main-class="ca.wim.passport.startup"/>
    </jnlp>I am not sure what the problem is.
    "I am unable to Download the application in the Java Web Start"
    If webstart in not actually downloading the jar - is the jar in the correct location?
    Is the server named dev01 and the directory structure actually /Dummy/New?
    Note: you do need to set up the mine type JNLP on your server,
    In my case the location of the JNLP file and main jar file passport is in the following directory.
    c:\Inetpub\WIMRoot\application
    The additional jars are in
    c:\Inetpub\WIMRoot\application
    I hope this may give you some clue
    rykk

  • To Run standlone Application

    Hi,
    When we run standlone application using "java" in comand promt there are some options like
    -D, -X etcs.
    I'm trying to run a application but not able to find out the parameters passing.Can some body explain it in details....like what -Dmq.port,-Dmq.host ,-Dlog.configuration etcs tends for....
    Rgds
    Ujjal
    java -Dmq.host=10.10.15.32 -Dmq.port=1414 -Dmq.channel=TO.MQCAUXT1 -Dmq.qmanager=MQCAUXT1 -Dmq.input.qname=AART.SI.IMPORTJOBS -Dlog.configuration=c:\projects\steelroads\properties\ImportSchedulerLog4j.properties com.steelroads.SI.fileimport.Importer 10402

    Hi !
    Don't know for sure...but my guesses are:
    -Dmq.host=10.10.15.32 Host used or contacted by the program
    -Dmq.port=1414 Port used or contacted by the program
    -Dmq.channel=TO.MQCAUXT1 Channel used or contacted by the program
    -Dmq.qmanager=MQCAUXT1 Query manager ??
    -Dmq.input.qname=AART.SI.IMPORTJOBS Query name ??
    -Dlog.configuration=c:\projects\steelroads\properties\mportSchedulerLog4j.properties Properties file used
    The ones above are just guesses from the names of the parameters...for better answers you should contact the guys at steelroads.com
    See ya
    Udo

  • How to run native program with Java program?

    Hello
    I've got following problem. I'd like to write file browser which would work for Linux and
    Windows. Most of this program would be independent of the system but running programs not. How to run Linux program from Java program (or applet) and how to do it in Windows?.
    Cheers

    Try this:
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("ls -l");
    InputStream stream = proc.getInputStream();
    InputStreamReader isr = new InputStreamReader(stream);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null) .....
    "if the program you launch produces output or expects input, ensure that you process the input and output streams" (http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html)

  • Getting GTK error while running javaFX application on linux

    I developed an JavaFX application that works fine on Windows. So, I tried to run this same application on Linux (ubuntu x86) and it is not working. I setup all the environment with following this article : http://docs.oracle.com/javafx/2.0/release_notes_linux/jfxpub-release_notes_linux.htm. The Sample JavaFX applications available at http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html work great on Linux. But when I run my application, I got this error:
    java -jar prototipoGui.jar
    Exception in thread "main" java.lang.RuntimeException: Application launch error
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:122)
    at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._invokeLater(Ljava/lang/Runnable;)V
    at com.sun.glass.ui.gtk.GtkApplication._invokeLater(Native Method)
    at com.sun.glass.ui.Application.invokeLater(Application.java:336)
    at com.sun.javafx.tk.quantum.QuantumToolkit.defer(QuantumToolkit.java:617)
    at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:138)
    at com.sun.javafx.application.PlatformImpl.runAndWait(PlatformImpl.java:171)
    at com.sun.javafx.application.PlatformImpl.tkExit(PlatformImpl.java:264)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:417)
    at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
    at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
    ... 1 more

    I get the same message, when running my application in stand alone.
    May be there is a problem when running in aa KDE environment.
    But I developed my app in Eclipse under KDE4. If the app is started by IDE it runs.

  • Run windows services from java application

    can java application run a windows server
    i have a web server that runing using tomcat and mysql
    can i make a icon in the systray
    that give me the option to (using a menu)
    run the server ,wicth means : tomcat and mysql are runing
    stop the server
    get tomcat stacktrace in a window
    i was thinking about runing tomcat and mysql as services
    and write the systray application using java,
    the systray application should acces window services ,
    and run/stop requierd services.
    what happend on a machine thar runs linux?
    thanks
    shay

    Ok .so it's will be a diffrent way under linux..
    for systray i will use http://systray.sourceforge.net/
    and for services i'll use the
    "net start <Service>" and "net stop service"
    i need to keep track on the service status
    so my Systray status will be updated
    what is the command for getting the status of the proccess
    thanks shay

  • 'Unable to Launch Application Error' - Java Web Start Running Under MS IIS.

    I am attempting to render the following .jnlp in MS IE:
    <?xml version="1.0" encoding="utf-8"?>
    <!-- JNLP File for LottoMadness Application -->
    <jnlp
       codebase="http://localhost/LottoMadness/"
       href="LottoMadness.jnlp">
       <information>
         <title>LottoMadness Application</title>
         <vendor>Rogers Cadenhead</vendor>
         <homepage href="http://localhost/LottoMadness/"/>
         <icon href="lottobigicon.gif"/>
       </information>
       <resources>
         <j2se version="1.5"/>
         <jar href="LottoMadness.jar"/>
       </resources>
       <application-desc main-class="LottoMadness"/>
    </jnlp>I've deployed the .jnlp, .gif, and .jar to MS IIS, running locally on my PC.
    When I attempt to render the .jnlp in IE I obtain an 'Application Error' window stating 'Unable to Launch Application'. Clicking details gives me:
    com.sun.deploy.net.FailedDownloadException: Unable to load resource: http://localhost/LottoMadness/LottoMadness.jnlp
         at com.sun.deploy.net.DownloadEngine.actionDownload(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResourceCacheEntry(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
         at com.sun.deploy.net.DownloadEngine.getResource(Unknown Source)
         at com.sun.javaws.Launcher.updateFinalLaunchDesc(Unknown Source)
         at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
         at com.sun.javaws.Launcher.launch(Unknown Source)
         at com.sun.javaws.Main.launchApp(Unknown Source)
         at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
         at com.sun.javaws.Main$1.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)I have configured MS IIS for Web Start, by setting the Extension/Content Type fields to .jnlp and application/x-java-jnlp-file.
    (The .jnlp is basically from 'Programming with Java in 24 Hours', as this is the book I am learning Java from.)

    AndrewThompson64 wrote:
    I am not used to seeing references to a local server that do not include a port number.
    E.G. http://localhost:8080/LottoMadness/
    I have deployed the following HTML (HelpMe.html) to the web server:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
         <title>Untitled</title>
    </head>
    <body>
    Help Me!
    </body>
    </html>When I attempt to render the URL in IE, I see the page just fine. The URL is use is:
    http://localhost/LottoMadness/HelpMe.htmlSo, I think my web server setup and usage is ok.
    >
    As an aside, what happens if (your MS IIS is running and) you click a direct link to..
    [http://localhost/LottoMadness/LottoMadness.jnlp|http://localhost/LottoMadness/LottoMadness.jnlp]
    When I click this link I get the error and exception I cited in my previous post.

  • How to run an application i created in java without using eclipse

    Im familiar with running an application i create thru command prompt or eclipse, how do i create a file to run on any computer with java so i can double click the file and my application runs. C# automatically does this, do i need to do an extra step to the jar file?

    Hi,
    You need to make an executable JAR file. There are a few ways you can do this but since you are using Eclipse you can follow this tutorial.
    [http://www.fsl.cs.sunysb.edu/~dquigley/cse219/index.php?it=eclipse&tt=jar&pf=y]
    The most important part is the manifest file, if you have dependencies on other JAR files they will need to be specified along with the
    main method to call to start you program. You can do this via the Eclipse Wizard.
    It will be in your interests to read this tutorial also
    [http://java.sun.com/docs/books/tutorial/deployment/jar/]

  • Java.lang.NoSuchMethodError while running the Application on MI client

    Hi Experts
    During development I run my application through NWDS and worked perfect. But when I  run my application only through MI client. It through error on my programmed methods: java.lang.NoSuchMethodError:
    Any advice is highly appreciated!
    Michal

    Thanks for your reply!
    I use MI 2.5 SP20 and that trace is:
    Internal Servlet Error:
    java.lang.NoSuchMethodError: com.sap.myApp.bean.TableViewBean.setAll(Ljava/lang/String;)V
    Thanks for any advice

Maybe you are looking for