Can a running java program reset itself internally so it ...

so it behaves just as if it was run for the first time!
Thank you

Something like this?Runtime.getRuntime().exec("java thisClass");
System.exit(0);

Similar Messages

  • Can't run java program with GUI

    My computer can run java program properly.
    However, for those program with GUI (using swing),
    my computer is unable to display the GUI.
    What's wrong with it? Is there any PATH I need to set before running GUI program?
    Thanks
    icedgold

    Cut, copy, paste then compile and run this;-import java.awt.*;
    import javax.swing.*;
    public class MyJFrame extends JFrame {
      public MyJFrame() {
          super("My first JFrame");
          Container c  = getContentPane();
          JPanel panel = new JPanel();
          panel.setBackground(Color.white);//  (new Color(255, 255, 255));
          JLabel jl = new JLabel("Yes it works");
          panel.add(jl);     
          c.add(panel);
      public static void main(String[] args) {
        MyJFrame frame = new MyJFrame();
        frame.setSize(180,120);
        frame.setLocation(200, 300);
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setVisible(true);
    }

  • Can't Run Java Programs -- java.lang.NoClassDefFoundError Error

    I am running 10.4.11. For some reason I can no longer run Java programs. (I could in the past)
    For example. I create a simple Hello World program as follows and save it as Hello.java:
    class HelloWorld
    public static void main (String args[])
    System.out.println("Hello, world!");
    Then I compile it:
    Javac Hello.java
    Then I try to run it:
    java Hello
    But I get this error:
    Exception in thread "main" java.lang.NoClassDefFoundError: Hello
    I think it must be a CLASSPATH problem but normally you do not need to worry about ClassPATH. Apple sets it up for you out of the box.
    What is wrong?

    I totally forgot that the class name should be the same as the filename.
    After I renamed the file to HelloWorld.java and recompiled, I could run "java HelloWorld"
    Rob

  • Can i run java program in the same way of .exe program?

    I am beginner in java and i'd like to know that java program can run in the same of .exe program(double click program icon) , instead of typing "java [class name]" or
    choose execute botton from forteCE.
    Thank you for your help
    [email protected]

    You can write a .bat script which launches the java command for you:
    @echo off
    java <your prog name here>
    Then move your .bat file icon wherever you want...
    bye
    Michele
    Tip: if you don't want to see the black VM window, try javaw instead of java.

  • Can't run java programs

    I'm having trouble getting java programs to run on my computer. I have no problem compiling programs but whenever i try to run them through the command prompt window i get the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: hello
    where 'hello' is the name of the 'hello world' test program i made (just prints the words 'hello world' world on screen.)
    The programs run on eclipse but i really prefer using the good old command prompt window. Can anyone explain to me what's wrong here (I'm guessing it's some sort of windows/java sdk setting that must be off.) Thanks in advance!!!

    I thought that this was resolved a couple days ago but apparently it wasn't (it was the temporary fix that was working.)
    I still get the same noclasseffounderror whenever i try to run the java program. The link tells me to add the correct 'path' to the system folder to make it work. It's actually already there (otherwise the javac command wouldn't work either.) However, the java programs do run whenever i execute the command
    set classpath=
    However, i have to do this every single time i open up a new shell window. Anybody know what the problem could be given that it works when i 'clobber it into working' as the tutorial put it?

  • Can't run Java Programs from home computer

    Hi, sorry if this is a simple problem.
    I downloaded Java version 1.4.0_03 but can't get it to work. I have configured the PATH variable and the CLASSPATH but it isn't working.
    If I type java -version the right stuff comes up.... so where have I gone wrong?
    Any ideas much appreciated
    Thanks
    cat

    I downloaded JDK
    this is whats in the PATH variable:
    ;C:\Program Files\Java\j2re1.4.0_03\bin
    and in the CLASSPATH:
    .;C:\Program Files\PhotoDeluxe HE 3.0\AdobeConnectables;C:\Program Files\Java\j2re1.4.0_03\lib\tools.jar

  • Can we able to run java program inside  javascript

    Hi all
    can we able to run java program inside javascript or integrate java with javascript.....whether its possible...

    No. You can't execute Java code from within a JS script in Acrobat/Reader.

  • Running java program at windows startup

    I need to run java program at startup and then it will continue to run in its own thread.
    Any body having idea how to do that programmatically?
    Zeeshan

    This is one option but this is not feasible in my scenario as this application will be running over a network which involves hundreds of computer so is there any way to do it programatically?
    I mean if I can load java class file through an exe file then I can load my class file in the startup using C++.
    Any Suggestions.
    thanks for the help
    regards,
    Zeeshan

  • Run java program in background

    I want to run a java program in background in windowsXP...can anyone help please......can anyone suggest an easy software for running java program as windows service...i tried one but without any success

    How many of the links here have you tried while you were waiting for an answer?
    http://www.google.com/search?q=running+java+program+as+windows+service
    (Note that the query is a direct copy/paste from your post.)

  • How to run java program from website?

    Hello
    I'd like to know how to run java program from my web page.
    I'd like to push some button in this web page so java program that would be on my server
    would pop-up. Can it be done automaticaly upon running this web site? (without any buttons - I just enter website and program pops up).
    Cheers

    I rather thought about RMI. But I could try servlets. So how it would look like?.
    I would make http request in browser (enter address) and program would show up in its window?. And I would not have to change anything in my program?. This program would run then on both boxes?. One remotely and one not?.
    But I would have to learn some basics, I've never worked with servlets. Could you suggest some good sites about it?. With ready examples so I could tweak them to my purpose.
    Message was edited by:
    macmacmac

  • Compile and run java programs in different directroy

    Hi,
    I often encounter many problems when I run java programs in the different directories. Like
    javac -d dir_name a.java
    java -cp dir_name a
    Something wired often happens, such as, there is not a.java file in some directory, but javac -d dir_name a.java can still work or "java -cp dir_name a" often doesn't work. Moreover, file_name.jar is also a tough problem and solving compiling problems is often time-consuming.
    So I hope to read something about how to compile and run java programs in different directory properly.
    Could you pleae give me a detailed description for that or recommend a book or website?
    Thanks a lot.

    Can you post a small amount of code that does not work, including the directory structure, and the error messages? Some one here can likely explain the problem.

  • I want to run java program on windows environment as background process

    Hi all
    I want to run java program on windows environment as background processSo command prompt return after executing java command and program on background In Linux we can do this easily �but I do not how to do this in windows
    for example look this programe
    import java.io.*;
    import java.util.*;
    public class TestClass {
         class ravi extends Thread{
              public void run(){
                   try {    
                        String target_file = "ravind.txt";
                        File targetfile = new File(target_file);
                        PrintWriter writer = new PrintWriter(new FileWriter(targetfile)) ;
                   for (int i =0 ; i < 100 ;i++ ){
                        Thread.sleep(10000);
                        writer.println(" ravindra shukla ");
              } catch (Exception e) {               
                             e.printStackTrace();
         public static void main(String[] args) {
              TestClass test1 = new TestClass();
              TestClass.ravi r1 = test1.new ravi();
              r1.start();          
    System.out.println(" return from main ");
    first i compile this
    javac TestClass.java
    then i run this by using this command
    java TestClass
    but becouse i put sleep on threads run function so it takes to much time to get return on command promt .... i want to run this programe as background process so command promt return as soon as i execute java command

    Thanks dude
    This solution �start java TestClass� works fine �. But it does not solve my problem
    It opens another black window and that black window persist till the life time of my program
    Is it possible application run on complete background without opening another black window �as in Linux

  • Can i call java program from VC++ code...... Urgent!

    hi,
    I have VC++ code.
    I want to run java program from VC++ (SDK).
    Can I call it?
    plz help it's urgent....
    thanks in advance...

    We do it all the time using the JNI invocation API (this is actually how the java.exe application works).
    Here's a tutorial I just found (not sure how good it is, but it should get you going):
    http://www.inonit.com/cygwin/jni/invocationApi/
    One note: If you are going to be invoking the JVM from different threads in your native app, there is some special handling you will have to do - the above tutorial doesn't address this scenario (a dig through the JNI docs should help with that one, though).
    Cheers,
    - K

  • Can't run some programs after system restore to remove virus

    Hi,
    My duaghter's Toshiba had a nasty virus that pretended to be an antivirus software product, that snuck in, between the time her default Norton service expired and I had the time to install Trend.
    Could not remove it using Trend, so upon advice from a friend, decided to do a windows system restore to a point prior to the infection. This worked successfully, and the virus is gone, but now she can't run some programs, I have tried to install Trend again, but that fails as it says that you have to uninstall Norton first. But I can't run Norton, or uninstall it, and some folders on C: are no longer accessible.
    Should I do a complete Toshiba system restore (ie back tofactory settings? This seems a drastic measure, but the issue is beyond my meagre PC skills.
    Thanks,
    Graeme

    Thanks for your reply.
    The main issue is that we cannot run the Norton Anitvirus that came prepackaged with the laptop, and we can't uninstall it either. If you try to perform either action, nothing happens.
    However, when we try to install a new antivirus software, Trend, the install fails because it detects that Norton is installed, and indicates that we must uninstall Norton before we can complete the Trend installation. But we cannot unistall Norton for some reason.
    I am getting my daughter to check what else doesn't work, but Microsoft Office works OK, and most of the games she installed seem to work. I just don't understand why Norton won't work now, and why we cannot uninstall it. I don't know if its due solely to the system restore, or some combination of events. The introductory 3 mont Norton licence has expired some time ago, but it should still let us uninstall. I have also tried to unistall through the Control panel, but nothing happens when I try that either.
    Is there any way to force the uninstall of Norton? Or is a factory reset the only viable option now?
    Thanks,
    Graeme

  • How to run java program on clients system when system strats

    hi
    I want to run java program on clients computer automatically when system boots up. plzzzzz help me .......

    You can add the call to the java program to the auto start group (under windows).
    You can't start a client program when the server starts, if that is what you mean.
    Timo

Maybe you are looking for