Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6887935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:56:46+00:00 2026-05-27T05:56:46+00:00

When I run my application and scan for an IP it freezes for some

  • 0

When I run my application and scan for an IP it freezes for some reason. Also, I am not sure if the Yum method is exiting once it run the command, or if it lives forever. My target was to make something like $ ./inLinuxRunMe &, where it runs in the background, and when the job is done, it kills itself.

I don’t think that my Yum method is doing this, because it freezes when I start heavy loads such as playing video’s etc.

public class MyShell
{
    public static String whatIsMyIP = null;

    public static void main(String args[])
    {
      t = new javax.swing.Timer(10000, new ActionListener() 
      {
        public void actionPerformed(ActionEvent ae) 
        {
        /* Scanner: if the ip change, show the new on too. */
        whatIsMyIP = MyShell.Yum("ifconfig eth0 | grep inet").toLowerCase());           
            /* Some logical conditions ... such as if ran then dont run, run once etc..*/ 
            bootMe();
         }
      });
      t.start();

      /* Launch: Main application server, runs forever as server */
      // MyShell.Yum("java -cp myjar.jar launch.MainApplicationAsServer");
    }

    /* Boot loader */
    public static void bootMe() throws IOException
    {
      MyShell.Yum("java -cp myjar.jar launch.MainApplicationAsServer");
    }

    /* Question: How to optimize it? So that, 
             it execute the shell command and quite*/
    public static String Yum(String cmds)
    {
        String value = "";
        try 
        {
          String cmd[] = {"/bin/sh", "-c", cmds };       
          Process p=Runtime.getRuntime().exec(cmd);       
          BufferedReader reader=new BufferedReader(
                                                                            new InputStreamReader(p.getInputStream())); 
          String line=reader.readLine(); 

          while(line!=null) 
          { 
            value += line ;
            line=reader.readLine(); 
          } 
          p.waitFor(); 

        } catch(IOException e1) {
        } catch(InterruptedException e2) { 
        }
        return value;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:56:46+00:00Added an answer on May 27, 2026 at 5:56 am

    From the Java API:

    Constructor Summary
    Timer(int delay, ActionListener listener)
          Creates a Timer that will notify its listeners every `delay` milliseconds.
    

    So it repeats every 10 seconds. You need to tell it not to repeat:

    public void setRepeats(boolean flag)
    
        If flag is false, instructs the Timer to send only one action event to its listeners.
    
        Parameters:
            flag - specify false to make the timer stop after sending its first action event
    

    So:

    t = new javax.swing.Timer(10000, new ActionListener() {...});
    t.setRepeats(false);
    t.start();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question: What command do you type in to the Run Application box on ubuntu
when I call Application.Run() on a form, this command halts the program until the
I have a Web application and have run a XSS scan on it and
Some installations that run our applications can be under hefty stress on a busy
I developed one swing application but each time you run application new window is
Always when I run java application it will display in Windows Task Manager is
When you run an application from within visual studio, it seems to pick a
I try to run jsf application in myeclipse using jboss web server and following
when i run my application it is the error i get... This application has
I am trying to run an application that normally works when I install on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.