SwingWorker problem!!! How can I run it 2 times or more?

Hello!!
I am new in Java. I use the following code:
SwingWorker SWorker = new SwingWorker<String, Void>()
   public String doInBackground() {
   return CargarInformacion();
public void done() {
   try {
      JTextAreaReport.append(get());
   } catch(InterruptedException ie)
      System.out.println(ie.toString());
   } catch(java.util.concurrent.ExecutionException ee)
      System.out.println(ee.toString());
private String CargarInformacion()
   try
      in = new BufferedReader(new FileReader(file));
      <read file...>
   return StrMessage;
}The problem is that when this code runs for the first time it works perfect!!! but I need to use it several times with other file names. In the java docs I found the following text:
"SwingWorker is only designed to be executed once. Executing a SwingWorker more than once will not result in invoking the doInBackground method twice."
How can I resolve this?
thank's.
David.
Edited by: davigre on Oct 1, 2008 8:42 PM

I am trying to do this as well. For some reason, it is not working for me. I have a class "Task" that extends Swingworker with a doInBackground() and done(). Each time I click "submit" I create a new "Task" and call task.execute(). But the second time around, the doInBackground() never gets called. Can someone help me out? Here are a couple of the relevant functions.
Thanks
Mike
Here is where the thread is started:
public void readDataLogger() {
        jButton.setEnabled(false);
        jBox.setEnabled(false);
        String deleteData = JOptionPane.showInputDialog("Would you like to erase all the data off this logger after it is downloaded? (y/n)");
        if (deleteData == null || deleteData.equalsIgnoreCase("n") || deleteData.equalsIgnoreCase("no")) {
            // user clicked cancel or typed n/no
        } else if (deleteData.equalsIgnoreCase("y") || deleteData.equalsIgnoreCase("yes")) {
            erase = true;
        routeNum.setText("Route Num: " + (String) jBox.getSelectedItem());
        waiting.setText("Please wait a moment...");
        Thread stepper = new BarThread(progressBar);
        stepper.start();
        this.add(progressBar);
        Task task = new Task();
        task.execute();
    }And the thread classes:
class BarThread extends Thread {
        JProgressBar progressBar;
        public BarThread(JProgressBar bar) {
            progressBar = bar;
        public void run() {
    class Task extends SwingWorker<Void, Void>{
        boolean wrongPort;
        long timeGoneBy = 0;
         * Main task. Executed in background thread.
        public Void doInBackground() {
            wrongPort = true;
            try {
                logWriter.append("starting new thread");
                logWriter.flush();
            } catch (IOException ex) {
                Logger.getLogger(DDAGPS.class.getName()).log(Level.SEVERE, null, ex);
            Runtime rt = Runtime.getRuntime();
            File propertiesFile = new File("port.properties");
            Properties properties = new Properties();
            String command = "";
            int portTry = 0;
            boolean propPort = false;
            if (propertiesFile.exists()) {
                try {
                    properties.load(new FileInputStream("port.properties"));
                } catch (IOException ex) {
                    ex.printStackTrace();
                if (properties.containsKey("port")) {
                    portTry = Integer.parseInt((String) properties.get("port"));
                    try {
                        logWriter.append("port from properties: " + portTry + "\r\n");
                        logWriter.flush();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    command = baseDir + "GPSBabel/gpsbabel.exe -p \"\" -w -t -i mtk";
                    if (erase) {
                        command += ",erase";
                    command += " -f com" + portTry + ": -o gpx,gpxver=1.0 -F " + baseDir + "Temp/" + jBox.getSelectedItem() + "-" + numbLoggers + ".gpx";
                    launching.setText("trying it on COM" + portTry);
                    try {
                        logWriter.append("command using port from props: " + command + "\r\n");
                        logWriter.flush();
                        Process p = rt.exec(command);
                        File bin = new File(baseDir + "data.bin");
                        boolean fileExists = false;
                        double time = 0.0;
                        while (!procDone(p) && !fileExists && time < 10) {
                            logWriter.append("waiting and looking for bin file: " + time + "\r\n");
                            logWriter.flush();
                            Thread.sleep(200);
                            time += .2;
                            if (bin.exists() && bin.length() > 0) {
                                wrongPort = false;
                                launching.setText("it worked on COM" + portTry + ", building data file...");
                                propPort = true;
                                fileExists = true;
                        if (!fileExists) {
                            logWriter.append("it did not work using the port from the properties file");
                            logWriter.flush();
                    } catch (IOException ex) {
                        try {
                            logWriter.append("error: " + ex.getMessage() + " trying to use GPSBabel with port from properties file\r\n");
                            logWriter.flush();
                        } catch (IOException ex1) {
                            ex1.printStackTrace();
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
            //if (!propPort) {
                try {
                    Process p = rt.exec("mode.com");
                    String s = null;
                    ArrayList<Integer> ports = new ArrayList<Integer>();
                    BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
                    logWriter.append("Here is the standard output of the command:\r\n");
                    logWriter.flush();
                    int lines = 0;
                    int po = -1;
                    while ((s = stdInput.readLine()) != null) {
                        String port = "";
                        logWriter.append("line: " + s + "\r\n");
                        logWriter.flush();
                        if (lines > 0) {
                            if (s.contains("Baud") && s.contains("115200")) {
                                logWriter.append("adding port: " + po + "\r\n");
                                logWriter.flush();
                                ports.add(po);
                            lines--;
                        if (s.startsWith("Status for device COM")) {
                            port = s.substring(s.indexOf("M") + 1, s.indexOf(":"));
                            po = Integer.parseInt(port);
                            lines = 2;
                    stdInput.close();
                    portTry = 0;
                    logWriter.append("wrongPort: " + wrongPort);
                    logWriter.flush();
                    while (portTry < ports.size() && wrongPort) {
                        command = baseDir + "GPSBabel/gpsbabel.exe -p \"\" -w -t -i mtk";
                        if (erase) {
                            command += ",erase";
                        command += " -f com";
                        command += ports.get(portTry) + ": -o gpx,gpxver=1.0 -F " + baseDir + "Temp/" + jBox.getSelectedItem() + "-" + numbLoggers + ".gpx";
                        System.out.println("command: " + command);
                        Long currentTime1 = System.currentTimeMillis();
                        launching.setText("trying it on COM" + ports.get(portTry));
                        logWriter.append("command: " + command + "\r\n");
                        logWriter.flush();
                        p = rt.exec(command);
                        boolean fileExists = false;
                        while (!procDone(p) && wrongPort && !fileExists) {
                            Thread.sleep(100);
                            long currentTime2 = System.currentTimeMillis();
                            timeGoneBy = (currentTime2 - currentTime1);
                            Long seconds = timeGoneBy / 1000;
                            int hundreds = (int) (timeGoneBy / 100) % 10;
                            timer.setText(seconds + "." + hundreds + " s");
                            logWriter.append("still working: " + seconds + " seconds\r\n");
                            logWriter.flush();
                            File bin = new File(baseDir + "data.bin");
                            if (!(bin.exists() && bin.length() > 0)) {
                                wrongPort = true;
                            } else {
                                logWriter.append("bin exists: " + bin.exists() + "\r\n");
                                logWriter.flush();
                                //File port = new File(baseDir + "port.properties");
                                //FileWriter fw = new FileWriter(port);
                                //fw.append("port=" + String.valueOf((ports.get(portTry))));
                                //fw.flush();
                                //fw.close();
                                launching.setText("it worked on COM" + ports.get(portTry) + ", building data file...");
                                wrongPort = false;
                            if (seconds > 15) {
                                takeAWhile.setText("This could take a minute or two depending on how much data you have to pull off.");
                            File file = new File(baseDir + "Temp/" + jBox.getSelectedItem() + "-" + numbLoggers + ".gpx");
                            if (file.exists()) {
                                fileExists = true;
                            logWriter.append("wrongPort: " + wrongPort + "\r\n");
                            logWriter.flush();
                            logWriter.append("fileExists: " + fileExists + "\r\n");
                            logWriter.flush();
                            logWriter.append("procDone: " + procDone(p) + "\r\n");
                            logWriter.flush();
                        portTry++;
                } catch (IOException ex) {
                    ex.printStackTrace();
                } catch (InterruptedException ex) {
                    ex.printStackTrace();
            return null;
        private boolean procDone(Process p) {
            try {
                int v = p.exitValue();
                return true;
            } catch (IllegalThreadStateException e) {
                return false;
         * Executed in event dispatch thread
        public void done() {
            try {
                logWriter.append("in done!\r\n");
                logWriter.append("wrongPort: " + wrongPort);
                logWriter.flush();
            } catch (IOException ex) {
                Logger.getLogger(DDAGPS.class.getName()).log(Level.SEVERE, null, ex);
            launching.setText("");
            ddagps.repaint();
            File bin = new File(baseDir + "data.bin");
            if (wrongPort) {
                //wrongPort = false;
                String message = "Something went wrong.  Please make sure the device is turned on and replug the " +
                        "device into the USB port and hit OK.";
                int response = redo(message);
                if (response == 1) {
                    System.exit(0);
                } else {
                    timer.setText("");
                    readDataLogger();
            } else {
                try {
                    logWriter.append("i am in done's else!\r\n");
                    logWriter.flush();
                } catch (IOException ex) {
                    Logger.getLogger(DDAGPS.class.getName()).log(Level.SEVERE, null, ex);
                launching.setText("creating gpx file");
                ddagps.repaint();
                File file = new File(baseDir + "Temp/" + jBox.getSelectedItem() + "-" + numbLoggers + ".gpx");
                while (!file.exists()) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException ex) {
                        ex.printStackTrace();
                //System.out.println("f1 does not exist");
                numbLoggers++;
                ddagps.remove(progressBar);
                takeAWhile.setText("");
                Toolkit.getDefaultToolkit().beep();
                jBox.setEnabled(true);
                jButton.setEnabled(true);
                waiting.setText("Done!\n");
                String moreDevices = JOptionPane.showInputDialog("Do you have any more devices to enter in? (y/n)");
                if (moreDevices == null) {
                    // user clicked cancel
                } else if (moreDevices.equalsIgnoreCase("y") || moreDevices.equalsIgnoreCase("yes")) {
                    JOptionPane.showMessageDialog(null, "Hit OK when the next logger is plugged in.");
                    timer.setText("");
                    bin.delete();
                    readDataLogger();
                } else if (moreDevices.equalsIgnoreCase("n") || moreDevices.equalsIgnoreCase("no")) {
                    launching.setText("Merging files...");
                    ddagps.repaint();
                    int numb = numbLoggers - 1;
                    File f = new File(baseDir + "Temp/" + jBox.getSelectedItem() + "-" + numb + ".gpx");
                    while (!f.exists()) {
                        try {
                            Thread.sleep(200);
                        } catch (InterruptedException ex) {
                            ex.printStackTrace();
                    //System.out.println("f2 does not exist");
                    //System.out.println("found " + f.getName());
                    ParseAndCombineKMLs pack = new ParseAndCombineKMLs(numbLoggers, jBox.getSelectedItem());
                    if (pack.parseAndCombine()) {
                        f = new File(baseDir + "Output/" + jBox.getSelectedItem() + ".kml");
                        while (!f.exists()) {
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException ex) {
                                ex.printStackTrace();
                        //System.out.println("f3 does not exist");
                        Uploader up = new Uploader(upload);
                        if (up.pushFile(baseDir + "Output/" + jBox.getSelectedItem() + ".kml")) {
                            launching.setText("Upload Successful");
                            Runtime rt = Runtime.getRuntime();
                            try {
                                rt.exec("C:/Program Files/Mozilla Firefox/firefox.exe " + view + "?route=" + jBox.getSelectedItem());
                                bin = new File(baseDir + "data.bin");
                                bin.delete();
                                launching.setText("Launching browswer with your data...");
                            } catch (IOException ex) {
                                ex.printStackTrace();
                    try {
                        logWriter.close();
                    } catch (IOException ex) {
                        ex.printStackTrace();
    }Edited by: dmikester1 on Nov 5, 2008 8:50 AM

Similar Messages

  • I want to install my photoshop 5.0 limited edition but the pc displays i should check if it is a 32 or 64 bit application. i changed my windows os  from xp to win7 64 bit (i think that is the problem) how can i run my photoshop on this system?

    i want to install my photoshop 5.0 limited edition but the pc displays i should check if it is a 32 or 64 bit application. i changed my windows os  from xp to win7 64 bit (i think that is the problem) how can i install and run my photoshop 5.0 le on this system?

    Kglad Creative Suite 2 is only applicable to individuals affected by the activation server shut down.  A complete list of affected software titles can be found at Activation server shut down for Creative Suite 2, Acrobat 7, and Macromedia products.

  • Help my hard drive is being taken up by about 200gb of "other" memory, i am running time machine on an imac does does cause the problem how can i get rid of all "other" memory

    my problem is that most of my imac hard drive is being taken up by 200gb of "other' memory
    i am running time machine does this contribute
    how can i get rid of all "other" memory
    thanks

    JKOL96 wrote:
    i am running time machine does this contributex
    Some, possibly, but shouldn't be a problem.
    how can i get rid of all "other" memory
    Much of it is OSX and other things needed to run your Mac.
    See The Storage Display for an explanation, and don't miss the link to Where did my Disk Space go?

  • How can i run a java class file from shell?

    Hi all,
    I've a .class file named "File" that contains Main method, it is in the package "File2".
    How can I run it by shell command?
    PS: "java -cp . file" doesn't work it launch->
    Exception in thread "main" java.lang.NoClassDefFoundError: File2/File (wrong name: File2/File)
    Thanks in advance.

    Just to understand: is File2 ar jar archive or not? If it is a jar archive, have you tried open File2.jar? If File2 is a directory within the current directory, have you tried java -cp . File2/File? I just tested with a set of classes and it works... Let me be precise:
    * Let us imagine you are working in a directory whole path is PathToDir/
    * in this directory you have the classes put in a directory called File2
    * in order to launch File.class then you would have to invoke :
    cd PathToDir/ (just to be sure)
    java -cp . File2/File
    *if you were to do the following then you would have the problem you describe
    cd PathToDir/File2/
    java -cp . File

  • How can i run a jar file?

    hi there
    how can i run a far file on my pc. i have installed JRE 1.3.1, and set the classpath to C:\Program Files\JavaSoft\JRE\1.3.1_02\bin for the user variables, what else do i need to do to run it?

    Hi everyone.. i had a funny problem. Microsoft removed from registry and system the vm and i got the problem of java.dll and the registry problem when compiling.
    How did i resolve that?
    too easy:
    1. go to the registry and search the key "JavaSoft"
    2. add a Key with the name "Java Runtime Environment"
    3. select the new key and add a alfa-numeric Value with the name "CurrentVersion"
    4. set the value c:\jdk1.4 //the place of your jdk-version
    5. insert a new Key with the name "1.4"
    6. go to the new key and add an alfanumeric value with the name "JavaHome" and put the value c:\jdk1.4\jre\lib
    do this where you find the key Javasoft (in my registry was twice)
    i did it and got no problems

  • How can I run a SQL script file...

    How can I run a SQL script file from a location on my computer without providing the whole path?
    Is there some way I can set a "Working folder" in SQL Plus??
    Thanks!
    Tom

    You can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
    scripts.
    I would like to use another directory than the oracle/bin...
    How can I do this ??
    Hello,
    U can do this by this way:
    Save odm_script.sql file to the default Oracle
    directory i.e. Oracle-Home/bin and Run following command
    through SQL Plus.
    SQL>@Script_Name
    I hope this will resolve ur problem.
    Regards,
    Omer Saeed Khan.

  • How can I run a SubVi in background when a sequence is running in the main VI

    What I want to do is this
    When I push a button on the main VI, a SubVI (#1) must run and take data.
    At the same time, a sequence, in which there are other subVIs must run.
    My problem is that the subVI #1 does not run when I push the button. The sequence is running well. How can I run both the sequence and the subVI at the simultaneously?
    Solved!
    Go to Solution.

    Hey Hugo,
    Sounds like you'll just want to do some parallel loops. I'll attach a screenshot of a VI that has a sequence where the counter goes up to 3, then restarts, each time it reads the iteration count from the subVI above. (The subVI is just a while loop with the iteration count attached to the global)
    Each iteration of the sequence shows an increased count from the subVI via a global variable.
    Is this what you are looking for?
    Keep in mind that I just threw this together to show functionality, its got a lot of rough edges to it.
    Message Edited by Chris_VH on 03-30-2009 03:59 PM
    Chris Van Horn
    Applications Engineer
    Attachments:
    iteration.jpg ‏43 KB

  • How can I run Runtime.exec command in Java To invoke several other javas?

    Dear Friends:
    I met a problem when I want to use a Java program to run other java processes by Runtime.exec command,
    How can I run Runtime.exec command in Java To invoke several other java processes??
    see code below,
    I want to use HelloHappyCall to call both HappyHoliday.java and HellowWorld.java,
    [1]. main program,
    package abc;
    import java.util.*;
    import java.io.*;
    class HelloHappyCall
         public static void main(String[] args){
              try
                   Runtime.getRuntime().exec("java  -version");
                   Runtime.getRuntime().exec("cmd /c java  HelloWorld "); // here start will create a new process..
                   System.out.println("Never mind abt the bach file execution...");
              catch(Exception ex)
                   System.out.println("Exception occured: " + ex);
    } [2]. sub 1 program
    package abc;
    import java.util.*;
    import java.io.*;
    class HelloWorld
         public static void main(String[] args){
         System.out.println("Hellow World");
    } [3]. Sub 2 program:
    package abc;
    import java.util.*;
    import java.io.*;
    class HappyHoliday
         public static void main(String[] args){
         System.out.println("Happy Holiday!!");
    } When I run, I got following:
    Never mind abt the bach file execution...
    I cannot see both Java version and Hellow World print, what is wrong??
    I use eclipse3.2
    Thanks a lot..

    sunnymanman wrote:
    Thanks,
    But How can I see both programs printout
    "Happy Holiday"
    and
    "Hello World"
    ??First of all, you're not even calling the Happy Holiday one. If you want it to do something, you have to invoke it.
    And by the way, in your comments, you mention that in one case, a new process is created. Actually, new processes are created each time you call Runtime.exec.
    Anyway, if you want the output from the processes, you read it using getInputStream from the Process class. In fact, you really should read that stream anyway (read that URL I sent you to find out why).
    If you want to print that output to the screen, then do so as you'd print anything to the screen.
    in notepad HelloWorld.java, I can see it is opened,
    but in Java, not.I have no idea what you're saying here. It's not relevant whether a source code file is opened in Notepad, when running a program.

  • URGENT PLEASE:How can I run a a class file on the Apache server?

    Hi Guys and Gurus,
    I am seeking some favor all of experienced gurus, i.e.
    How can I run a a class file on the Apache server? Can I run through an Applet?
    How can I set Environment variables in Windows2000 Professional Environment?
    Actually, I want to extract some records from a MySQL Database running on Apache Server. I wrote a program just to select the columns and show them. It is now a Class file, Now how can I run this class file from the Server???
    The code is here
    import java.sql.*;
    public class RecordShow {
    public static void main(String args[]) {
    String url = "jdbc:mysql://localhost/myhost";
    Connection con;
    String query = "select mytable.column," +
    "from mytable " +
    "where mytable.column = 1";
    Statement stmt;
    try {
    Class.forName("com.mysql.jdbc.Driver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url,
    "myuser", "mypassword");
    stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    int rowCount = 1;
    while (rs.next()) {
    System.out.println("Row " + rowCount + ": ");
    for (int i = 1; i <= numberOfColumns; i++) {
    System.out.print(" Column " + i + ": ");
    System.out.println(rs.getString(i));
    System.out.println("");
    rowCount++;
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.print("SQLException: ");
    System.err.println(ex.getMessage());
    Please advise... THANKS
    VJ

    Ehm, I wasn't referring to you at all... read up,
    there's a comment by jschell saying that CGI might be
    easier/better for his purposes.
    Yep.
    I know PHP/Perl/whatever might be easier for some
    purposes, but only if you happen to know them and want
    to/are able to use them. Ok. But you aren't the one asking the question are you. And the person who asked the question seems to have absolutely no familiarity with Apache or applets.
    So whatever they do they are going to have to learn a lot.
    And that does indeed suggest that in all likelyhood they have not investigated the alternatives.
    And for the vast majority of internet applications, especially with smaller projects (obvious this person is not working with a large team), using perl, or something besides java, is going to be the best business solution. It is simpler, and more secure (probably due to the fact that it is simpler.)
    Since this is a Java forum, I
    answer under the assumption that people have made a
    choice one way or another to use a Java solution to
    their problem, so I try to solve it in Java first, and
    only when that fails (very seldom) do I turn to other
    solutions.You approach problems by arbritrarily deciding to try to solve it in java first and only if you fail do you then look to other solutions?
    My first step is to try to figure out which of the various avenues is going to cost less. (And a secondary, but non-trivial concern, is then to convince the customer that just because they have heard of a buzz word like 'enterprise bean' that it doesn't mean that is a cost effective solution.) We must come from different worlds.

  • Help:How can I run the J2EE Client Application? Thanks

    Help:How can I run the J2EE Client Application that will access the remote J2EE1.4 application server which runs on another host computer?
    I have developped a stateles senterprise java bean name converter and deloyed it in the j2ee1.4 application server on the host machine A. The converterbean provides the remote home interface and remote interface. At the same time I have developped the j2ee application client named convertappclient. When I access the conveter bean at host computer A through the script 'appclient.bat' as 'appclient -client convertappclient.jar', the client can access the bean sucessfully. Now I want to access the bean through the script 'appclient.bat' at host computer B,what files should I copy from host computer A to host computer B;and what the command line should be like? Thanks!
    The following are the code of the enterprise java bean and it's home interface .
    The client code is also provided.
    The enterprise java bean:
    package converter;
    import java.rmi.RemoteException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.math.*;
    public class ConverterBean implements SessionBean {
    BigDecimal yenRate = new BigDecimal("121.6000");
    BigDecimal euroRate = new BigDecimal("0.0077");
    public ConverterBean() {
    public BigDecimal dollarToYen(BigDecimal dollars) {
    BigDecimal result = dollars.multiply(yenRate);
    return result.setScale(2, BigDecimal.ROUND_UP);
    public BigDecimal yenToEuro(BigDecimal yen) {
    BigDecimal result = yen.multiply(euroRate);
    return result.setScale(2, BigDecimal.ROUND_UP);
    public void ejbCreate() {
    public void ejbRemove() {
    public void ejbActivate() {
    public void ejbPassivate() {
    public void setSessionContext(SessionContext sc) {
    The bean's remote home interface :
    package converter;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.EJBHome;
    public interface ConverterHome extends EJBHome {
    Converter create() throws RemoteException, CreateException;
    The bean's remote interface:
    package converter;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    import java.math.*;
    public interface Converter extends EJBObject {
    public BigDecimal dollarToYen(BigDecimal dollars) throws RemoteException;
    public BigDecimal yenToEuro(BigDecimal yen) throws RemoteException;
    The j2ee application client:
    import converter.Converter;
    import converter.ConverterHome;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.rmi.PortableRemoteObject;
    import java.math.BigDecimal;
    public class ConverterClient {
    public static void main(String[] args) {
    try {
    Context initial = new InitialContext();
    System.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
                   System.setProperty("java.naming.provider.url","jnp://10.144.97.250:3700");
    Context myEnv = (Context) initial.lookup("java:comp/env");
    Object objref = myEnv.lookup("ejb/SimpleConverter");
    ConverterHome home =
    (ConverterHome) PortableRemoteObject.narrow(objref,
    ConverterHome.class);
    Converter currencyConverter = home.create();
    BigDecimal param = new BigDecimal("100.00");
    BigDecimal amount = currencyConverter.dollarToYen(param);
    System.out.println(amount);
    amount = currencyConverter.yenToEuro(param);
    System.out.println(amount);
    System.exit(0);
    } catch (Exception ex) {
    System.err.println("Caught an unexpected exception!");
    ex.printStackTrace();
    }

    Surprisingly I find an upsurge in the number of posts with this same problem. I recently found a post which gave a nice link for this. Follow the steps and it should help:
    http://docs.sun.com/source/819-0079/dgacc.html#wp1022105

  • How can I run Adobe AIR beta until my application is ready to be upgraded?

    How can I run Adobe AIR beta until my application is ready to be upgraded? How can I get around being forced to upgrade? Everything was working fine until the upgrade was forced. This is a huge problem for me

    You can use the Installation Tuner for Reader to customize the UI elements provided to the user.  Details on the Adobe web site.

  • How  can i run this code correctly?

    hello, everybody:
        when  i run the code, i found that it dons't work,so ,i  hope somebody can help me!
        the Ball class is this :
        package {
        import flash.display.Sprite;
        [SWF(width = "550", height = "400")]
        public class Ball extends Sprite {
            private var radius:Number;
            private var color:uint;
            private var vx:Number;
            private var vy:Number;
            public function Ball(radius:Number=40, color:uint=0xff9900,
            vx:Number =0, vy:Number =0) {
                this.radius= radius;
                this.color = color;
                this.vx = vx;
                this.vy = vy;
                init();
            private function init():void {
                graphics.beginFill(color);
                graphics.drawCircle(0,0,radius);
                graphics.endFill();
    and the Chain class code is :
    package {
        import flash.display.Sprite;
        import flash.events.Event;
        [SWF(width = "550", height = "400")]
        public class Chain extends Sprite {
            private var ball0:Ball;
            private var ball1:Ball;
            private var ball2:Ball;
            private var spring:Number = 0.1;
            private var friction:Number = 0.8;
            private var gravity:Number = 5;
            //private var vx:Number =0;
            //private var vy:Number = 0;
            public function Chain() {
                init();
            public function init():void {
                ball0  = new Ball(20);
                addChild(ball0);
                ball1 = new Ball(20);
                addChild(ball1);
                ball2 = new Ball(20);
                addChild(ball2);
                addEventListener(Event.ENTER_FRAME, onEnterFrame);
            private function onEnterFrame(event:Event):void {
                moveBall(ball0, mouseX, mouseY);
                moveBall(ball1, ball0.x, ball0.y);
                moveBall(ball2, ball1.x, ball1.y);
                graphics.clear();
                graphics.lineStyle(1);
                graphics.moveTo(mouseX, mouseY);
                graphics.lineTo(ball0.x, ball0.y);
                graphics.lineTo(ball1.x, ball1.y);
                graphics.lineTo(ball2.x, ball2.y);
            private function moveBall(ball:Ball,
                                      targetX:Number,
                                      targetY:Number):void {
                ball.vx += (targetX - ball.x) * spring;
                ball.vy += (targetY - ball.y) * spring;
                ball.vy += gravity;
                ball.vx *= friction;
                ball.vy *= friction;
                ball.x += vx;
                ball.y += vy;
    thanks every body's help!

    ok, thanks for your reply ! I run this code in the Flex builder 3!and the Ball class and the Chain class are all in the same AS project!
      and i changed the ball.pv property as public in the Ball class, and  the Chain class has no wrong syntactic analysis,but the AS code don't run.so this is the problem.
    2010-04-21
    Fang
    发件人: Ned Murphy <[email protected]>
    发送时间: 2010-04-20 23:01
    主 题: how  can i run this code correctly?
    收件人: fang alvin <[email protected]>
    I don't see that the Ball class has a pv property, or that you even try to access a pv property in the Chain class.  All of the properties in your Ball class are declared as private, so you probably cannot access them directly.  They would need to be public.  Also, I still don't see where you import Ball in the chain class such that it can use it.

  • How can i run .app executable  file

    Hi,
    While i was searching for my topic on google code, i found one project and i download that.
    But its "MyProject.app" with yellow cplored xcode sumbol and i can not run this file.
    Does any one know that how can i run this type of file. i want to run this project.
    And another question. I want to create executable file from my project like exe on windows. Is there any way to create this type of file????
    Thanks.

    vavdiyaharesh wrote:
    Hey,
    When i double click on .app file it quit and show me message like "The application project140 quit unexpectedly"........."
    So is there any problem in .app file?
    On your machine sure sounds like it.
    How can i create exe file and how can i pass -0 to compiler ..iu don;t see any option in xcode for that.....
    giove me solution...
    I think you'd be better off taking some training, or at least working through some of Apple's tutorials.
    http://developer.apple.com/documentation/developertools/conceptual/XcodeQuickTou r/qtintro/chapter_1_section1.html
    Thanks.
    You're welcome.

  • How can we run and control live images form a camera plz help

    hi
    i want to now how can we run and control live images form a camera on to a aaplet.what technologyi used for this project . u can check the url http://www.jal.co.jp/en/live/ as a demo.plz can anyone guide me.how to start and which technologies to use,
    regards
    sheetal

    Hi,
    You can try a package named: JTwain, which is available at http://asprise.com/product/jtwain.
    JTwain supports all kinds of digital cameras and scanners. You can use Java to access, contorl digital cameras and scanners, and of course, to acquire images with flexible settings.
    The developers' guide is available @ http://asprise.com/product/jtwain/devGuide.php
    In the simplest case, one line of Java code can solve your problem.
    Good luck!

  • How Can I Run A SQLJ Normal Project In SAP NWDS

    I have a question about SQLJ in SAP NWDS.
    1.I created a java dictionary project,and then create the table , then depoly it.it's ok.
    2.I created a java normal project including the above java dictionary project.
    3.I used the SQLJ tech in the java normal project,exporting the opensqllib.jar,sqljapi.jar,sqljc.jar,sqljimpl.jar.
    4.I coded the normal project,and export the project .jar,everything is ok.
    <b>5.But when i runed the project in NWDS,the error appeared:java.lang.NoClassDefFoundError: com/sap/sql/log/OpenSQLException
         at com.ezkj.deom.sqlj.MainApp.main(MainApp.java:21)
    Exception in thread "main"</b>
    How Can I Run A SQLJ Normal Project In SAP NWDS?
    PLS Help me and don't let me alone!

    Tony,
    Why not try to import your SQLJ project in SAP NWDS. Add all the jars mentioned to the project path both for compile time as well as runtime. Now try running he project. Once you are able to bypass java.lang.NoClassDefFoundError, you will get other errors related to SQL statements. These Oracle SQL statements needs to be converted to OpenSQL format.
    Chill out!!!
    Sukanta Rudra
    Note: If helpful, plz donate some points.

Maybe you are looking for