Problem with Threads and "plase wait..."-Window

Hi everyone,
I have a problem that I'm not able to solve in any way... I have a time-consuming task (a file decryption) which I execute in a separate thread; I've used the SwingWorker class, like suggested by sun-tutorial, and it works right. The problem is that I have to wait that the decryption have finished before continuing with program-execution. Therefore I would like to display a "please wait"-window while the task runs. I've tryed all the possible ways I know but the problem is always the same: the waitWindow is displayed empty, the bounds are painted but the contents no; it's only painted when the decrypt-task has finished. Please help me, I have no more resources....
decrypt-file code:
public class DecryptFile {
  private String cryptedFileNameAndPath;
  private ByteArrayInputStream resultStream = null;
  // need for progress
  private int lengthOfTask;
  private int current = -1;
  private String statMessage;
  public DecryptFile(String encZipFileNameAndPath) {
    cryptedFileNameAndPath = encZipFileNameAndPath;
    //Compute length of task...
    // 0 for indeterminate
    lengthOfTask = 0;
  public ByteArrayInputStream getDecryptedInputStream() {
    return this.resultStream;
   * Called from ProgressBarDemo to start the task.
  public void go() {
    current = -1;
    final SwingWorker worker = new SwingWorker() {
      public Object construct() {
        return new ActualTask();
   * Called from ProgressBarDemo to find out how much work needs
   * to be done.
  public int getLengthOfTask() {
    return lengthOfTask;
   * Called from ProgressBarDemo to find out how much has been done.
  public int getCurrent() {
    return current;
  public void stop() {
    current = lengthOfTask;
   * Called from ProgressBarDemo to find out if the task has completed.
  public boolean done() {
    if (current >= lengthOfTask)
      return true;
      return false;
  public String getMessage() {
    return statMessage;
   * The actual long running task.  This runs in a SwingWorker thread.
  class ActualTask {
    ActualTask () {
      current = -1;
      statMessage = "";
      resultStream = AIUtil.getInputStreamFromEncZip(cryptedFileNameAndPath); //here the decryption happens
      current = 0;
      statMessage = "";
  }The code that calls decryption and displays waitWindow
      final WaitSplash wS = new WaitSplash("Please wait...");
      final DecryptFile cryptedTemplate = new DecryptFile (this.templateFile);
      while (! cryptedTemplate.done()) {
        try {
        } catch (Exception e) { }
      this.templateInputStream = cryptedTemplate.getDecryptedInputStream();
      wS.close();Thanks, thanks, thanks in advance!

Maybe you can try setting the priority of the long-running thread to be lower? so that the UI will be more responsive...

Similar Messages

  • Problem with Thread and InputStream

    I am having a problem with threads and InputStreams. I have a class which
    extends Thread. I have created and started four instances of this class. But
    only one instance finishes its' work. When I check the state of other three
    threads their state remains Runnable.
    What I want to do is to open four InputStreams which are running in four
    threads, which reads from the same url.
    This is what I have written in my thread class's run method,
    public void run()
         URL url = new URL("http://localhost/test/myFile.exe");
    URLConnection conn = url.openConnection();
    InputStream istream = conn.getInputStream();
    System.out.println("input stream taken");
    If I close the input stream at the end of the run method, then other threads
    also works fine. But I do not want to close it becuase I have to read data
    from it later.
    The file(myFile.exe) I am trying to read is about 35 MB in size.
    When I try to read a file which is about 10 KB all the threads work well.
    Plz teach me how to solve this problem.
    I am using JDK 1.5 and Win XP home edition.
    Thanks in advance,

    I dunno if we should be doing such things as this code does, but it works fine for me. All threads get completed.
    public class ThreadURL implements Runnable
        /* (non-Javadoc)
         * @see java.lang.Runnable#run()
        public void run()
                URL url = new URL("http://localhost:7777/java/install/");
                URLConnection conn = url.openConnection();
                InputStream istream = conn.getInputStream();
                System.out.println("input stream taken by "+Thread.currentThread().getName());
                System.out.println("input stream closed by "+Thread.currentThread().getName());
            catch (MalformedURLException e)
                //TODO Handle exception.
            catch (IOException e)
                //TODO Handle exception.
        public static void main(String[] args)
            ThreadURL u = new ThreadURL();
            Thread t = new Thread(u,"1");
            Thread t1 = new Thread(u,"2");
            Thread t2 = new Thread(u,"3");
            Thread t3 = new Thread(u,"4");
    }And this is the o/p i got
    input stream taken by 2
    input stream closed by 2
    input stream taken by 4
    input stream closed by 4
    input stream taken by 3
    input stream closed by 3
    input stream taken by 1
    input stream closed by 1
    can u paste your whole code ?

  • Problem with JFrame and busy/wait Cursor

    Hi -- I'm trying to set a JFrame's cursor to be the busy cursor,
    for the duration of some operation (usually just a few seconds).
    I can get it to work in some situations, but not others.
    Timing does seem to be an issue.
    There are thousands of posts on the BugParade, but
    in general Sun indicates this is not a bug. I just need
    a work-around.
    I've written a test program below to demonstrate the problem.
    I have the problem on Solaris, running with both J2SE 1.3 and 1.4.
    I have not tested on Windows yet.
    When you run the following code, three JFrames will be opened,
    each with the same 5 buttons. The first "F1" listens to its own
    buttons, and works fine. The other two (F2 and F3) listen
    to each other's buttons.
    The "BUSY" button simply sets the cursor on its listener
    to the busy cursor. The "DONE" button sets it to the
    default cursor. These work fine.
    The "SLEEP" button sets the cursor, sleeps for 3 seconds,
    and sets it back. This does not work.
    The "INVOKE LATER" button does the same thing,
    except is uses invokeLater to sleep and set the
    cursor back. This also does not work.
    The "DELAY" button sleeps for 3 seconds (giving you
    time to move the mouse into the other (listerner's)
    window, and then it behaves just like the "SLEEP"
    button. This works.
    Any ideas would be appreciated, thanks.
    import java.awt.BorderLayout;
    import java.awt.Cursor;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    public class BusyFrameTest implements ActionListener
    private static Cursor busy = Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR);
    private static Cursor done = Cursor.getDefaultCursor();
    JFrame frame;
    JButton[] buttons;
    public BusyFrameTest (String title)
    frame = new JFrame (title);
    buttons = new JButton[5];
    buttons[0] = new JButton ("BUSY");
    buttons[1] = new JButton ("DONE");
    buttons[2] = new JButton ("SLEEP");
    buttons[3] = new JButton ("INVOKE LATER");
    buttons[4] = new JButton ("DELAY");
    JPanel buttonPanel = new JPanel();
    for (int i = 0; i < buttons.length; i++)
    buttonPanel.add (buttons);
    frame.getContentPane().add (buttonPanel);
    frame.setVisible (true);
    public void addListeners (ActionListener listener)
    for (int i = 0; i < buttons.length; i++)
    buttons[i].addActionListener (listener);
    public void actionPerformed (ActionEvent e)
    System.out.print (frame.getTitle() + ": " + e.getActionCommand());
    if (e.getActionCommand().equals ("BUSY"))
    frame.setCursor (busy);
    else if (e.getActionCommand().equals ("DONE"))
    frame.setCursor (done);
    else if (e.getActionCommand().equals ("SLEEP"))
    frame.setCursor (busy);
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.print (" finished");
    else if (e.getActionCommand().equals ("INVOKE LATER"))
    frame.setCursor (busy);
    SwingUtilities.invokeLater (thread);
    else if (e.getActionCommand().equals ("DELAY"))
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (busy);
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.print (" finished");
    Runnable thread = new Runnable()
    public void run()
    try { Thread.sleep (3000); } catch (Exception ex) { }
    frame.setCursor (done);
    System.out.println (" finished");
    public static void main (String[] args)
    BusyFrameTest f1 = new BusyFrameTest ("F1");
    f1.addListeners (f1);
    BusyFrameTest f2 = new BusyFrameTest ("F2");
    BusyFrameTest f3 = new BusyFrameTest ("F3");
    f2.addListeners (f3); // 2 listens to 3
    f3.addListeners (f2); // 3 listens to 2

    I've had the same problems with cursors and repaints in a swing application, and I was thinking of if I could use invokeLater, but I never got that far with it.
    I still believe you would need a thread for the time consuming task, and that invokeLater is something you only need to use in a thread different from the event thread.

  • Problem with Speaker and Headset in Windows Vista

    Hi, I just got my Macbook Pro 13" and having problem with speaker and headset when working with Windows Vista (I have installed the driver from bootcamp). The sound very weak if I play music from Itunes or youtube even the volume already full and if i put my headset the sound not coming out. Is there anyone can help me to solve this problem?

    When you post about Windows / Boot Camp, in Mac Pro (workstation) forum where others with a MacBOOK would be more likely to have same hardware configuration, and you won't find Windows drivers on Apple downloads. More like at or other sites, or go to RealTek (if that is the type of audio you have).

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
            objMainProcess.setDaemon( true );
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    bChanged = false;
                    return true;
                try {
                }catch( InterruptedException e ) {}
                return false;

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.

  • Problem with threads and ProgressMonitor

    Dear Friends:
    I have a little problem with a thread and a ProgressMonitor. I have a long time process that runs in a thread (the thread is in an separate class). The thread has a ProgressMonitor that works fine and shows the tasks progress.
    But I need deactivate the main class(the main class is the user interface) until the thread ends.
    I use something like this:
    LongTask myTask=new LongTask();
    Now, the main class waits for the task to end, but the progress monitor don`t works fine: it shows only the dialog but not the progress bar.
    What's wrong?

    Is the dialog a modal dialog? This can block other UI updates.
    In general, you should make sure that it isn't modal, and that your workThread has a fairly low priority so that the UI can do its updating

  • Problem with threads and camera.

    Hi everybody!
    I've a problem with taking snapshot.
    I would like to display a loading screen after it take snapshot ( sometimes i
    have to wait few seconds after i took snapshot. Propably photo is being taken in time where i have to wait).
    I was trying to use threads but i didn't succeed.
    I made this code:
            new Thread(new Runnable(){
                public void run() {               
                    while((!performing.isShown()) && (backgroundCamera.isShown())){
            new Thread(new Runnable(){
                public void run() {
                    try {
                    } catch(Exception e) {
                    photo = camera.snapshot();                               
            }).start();This code is sometimes showing performing screen but sometimes no.
    I don't know why. In my opinion performing.isShown() method isn't working correctly.
    Does anyone have some idea how to use threads here?

    I've finally managed to work this fine.
    The code:
           Object o = new Object();
            new Thread(new Runnable(){
                public void run() {               
                   synchronized(o) {
            new Thread(new Runnable(){
                public void run() {
                    try {
                        synchronized(o) {
                    } catch(Exception e) {
                    photo = camera.snapshot();                               

  • Problem with threads and graphics

    I have a thread that chooses paths for a Travelling salesman problem, it then calls a TSPdraw class and passes it the path, which the class then draws. the problem is when i have two threads it creates two windows but only draws a path in one of them. any ideas where i`m going wrong

    Are you using swing components? Swing isn't threadsafe. If you have multiple threads that want to update your UI you need to use the SwingUtilities.invokeLater(...)or invokeAndWait(...). There is a page in the swing tutorial about this at:

  • Problem with threads and/or memory

    I'm developing an application where there are 3 threads. One of them sends a request to the other, and if the 2nd can't answer it, it sends it to the 3rd (similar to CPU -> CACHE -> MEMORY). When i run the program with 1000-10.000 requests, no problem occurs. When i run it with 300.000-1.000.000 requests, it sometimes hangs. Is this a problem with the garbage collector, or should it be related to the threads mecanism.
    (note: eache thread is in execution using a finite state machine)

    i had been running the program inside Netbeans.
    Running the jar using the command line outside
    Netbeans i have no more problems... Does Netbeans use
    it's own JVM?Depends how you set it up, but look under the options. There are settings for the compiler and jvm that it uses.

  • Having a problem with threads and using locks

    I was hoping someone could give me some hits on getting my code to run properly. The problem I am having is I think my locks and unlocks are not working properly. Plus, for some reason I always get the same output, which is:
    Withdrawal Threads         Deposit Threads            Balance
    Thread 2 attempts $29 Withdrawal - Blocked - Insufficient Funds
    Thread 4 attempts $45 Withdrawal - Blocked - Insufficient Funds
    Thread 6 attempts $34 Withdrawal - Blocked - Insufficient Funds
    Thread 7 attempts $40 Withdrawal - Blocked - Insufficient Funds
                                    Thread 1 deposits $187          $187
                                    Thread 3 deposits $169          $356
                                    Thread 5 deposits $61           $417
    Press any key to continue...If someone can see the error I made and doesn't mind explaining it to me, so I can learn from it, I would appreciate that very much.
    import java.util.concurrent.*;
    public class Assign2_Main
    {//start Assign2_Main
        public static void main(String[] args)
        {//start main
               // create ExecutorService to manage threads
               ExecutorService threadExecutor = Executors.newCachedThreadPool();
            Account account = new SynchronizedThreads();
            Deposit deposit1 = new Deposit(account, "Thread 1");
            Deposit deposit2 = new Deposit(account, "Thread 3");
            Deposit deposit3 = new Deposit(account, "Thread 5");
            Withdrawal withdrawal1 = new Withdrawal(account, "Thread 2");
            Withdrawal withdrawal2 = new Withdrawal(account, "Thread 4");
            Withdrawal withdrawal3 = new Withdrawal(account, "Thread 6");
            Withdrawal withdrawal4 = new Withdrawal(account, "Thread 7");
            System.out.println("Withdrawal Threads\t\tDeposit Threads\t\t\tBalance");
            catch ( Exception e )
                //shutdown worker threads
        }//end main
    }//end Assign2_Main/**********************************************/
    public class Withdrawal implements Runnable
    {//start  class Withdrawal
        public Withdrawal(Account money, String n)
             account = money;
             name = n;
        public void run()
        {//start ruin
             int newNum = 0;
                newNum = account.getBalance(name); 
        }//end run
        private Account account;
        private String name;
    }//end  class Withdrawal/**********************************/
    import java.util.Random;
    public class Deposit implements Runnable
    {//start class Deposit
        public Deposit(Account money, String n)
             account = money;
             name = n;
        public void run()
        {//start run
                   account.setBalance(random.nextInt(200), name);
                }// end try
                catch (InterruptedException e)
       }//end run
       private Account account;
       private Random random = new Random();
       private String name;
    }//end class Deposit/*************************************/
    *Account interface specifies methods called by Producer and Consumer.
    public interface Account
         //place sum into Account
         public void setBalance(int sum, String name);
         //return  value of Account
            public int getBalance(String name);         
    } /******************************/
    import java.util.concurrent.locks.*;
    import java.util.Random;
    public class SynchronizedThreads implements Account
    {//start SynchronizedThreads
          *place money into buffer
        public void setBalance(int amount, String name)
        {//start setBalance
             // lock object
            sum += amount;
            System.out.println("\t\t\t\t" + name + " deposits $" + amount +"\t\t$"+ sum+"\n");       
               //threads are singnaled to wakeup
              // unlock object                                                
           }//end setBalance
            *gets the balance from buffer
           public int getBalance(String name)
        {//start getBalance
             int NewSum = random.nextInt(50);
             //lock object
                 if(sum > NewSum)
                     //takes NewSum away from the account
                     sum -= NewSum;
                        System.out.println(name + " withdraws $" + NewSum +"\t\t\t\t\t\t$"+ sum+"\n");
                     System.out.println(name +  " attempts $" + NewSum + " Withdrawal - Blocked - Insufficient Funds\n");                 
                     //not enough funds so thread waits
                //threads are singnaled to wakeup
                }//end try
            catch (InterruptedException e)
                 //unlock object
            return NewSum;     
         }//end getBalance
         private Random random = new Random();  
         private Lock myLock = new ReentrantLock();
         private Condition MakeD = myLock.newCondition();
         private Condition MakeWD = myLock.newCondition();
         private int sum = 0;
    }//end SynchronizedThreads

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|] about Basics of Java and Threads to know more about threads.
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • A problem with Threads and MMapi

    I am tring to execute a class based on Game canvas.
    The problem begin when I try to Play both a MIDI tone and to run an infinit Thread loop.
    The MIDI tone "Stammers".
    How to over come the problem?
    Thanks in advance
    See Code example below:
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    public class MainScreenCanvas extends GameCanvas implements Runnable {
         private MainMIDlet parent;
         private boolean mTrucking = false;
         Image imgBackgound = null;
         int imgBackgoundX = 0, imgBackgoundY = 0;
         Player player;
         public MainScreenCanvas(MainMIDlet parent)
              this.parent = parent;
                   imgBackgound = Image.createImage("/images/area03_bkg0.png");
                   imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
                   imgBackgoundY = this.getHeight() - imgBackgound.getHeight();
              catch(Exception e)
          * starts thread
         public void start()
              mTrucking = true;
              Thread t = new Thread(this);
          * stops thread
         public void stop()
              mTrucking = false;
         public void play()
                   InputStream is = getClass().getResourceAsStream("/sounds/scale.mid");
                   player = Manager.createPlayer(is, "audio/midi");
              catch(Exception e)
         public void run()
              Graphics g = getGraphics();
              while (true)
          * responsible for object movements
         private void tick()
          * response to key input
         private void input()
              int keyStates = getKeyStates();
              if ((keyStates & LEFT_PRESSED) != 0)
                   if (imgBackgoundX > 0)
                        imgBackgoundX = 0;
              if ((keyStates & RIGHT_PRESSED) != 0)
                   if (imgBackgoundX < this.getWidth() - imgBackgound.getWidth())
                        imgBackgoundX = this.getWidth() - imgBackgound.getWidth();
          * Responsible for the drawing
          * @param g
         private void render(Graphics g)
              g.drawImage(imgBackgound, imgBackgoundX, imgBackgoundY, Graphics.TOP | Graphics.LEFT);

    You can also try to provide a greater Priority to your player thread so that it gains the CPU time when ever it needs it and don't harm the playback.
    However a loop in a Thread and that to an infinite loop is one kind of very bad programming, 'cuz the loop eats up most of your CPU time which in turn adds up more delays of the execution of other tasks (just as in your case it is the playback). By witting codes bit efficiently and planning out the architectural execution flow of the app before start writing the code helps solve these kind of issues.
    You can go through [this simple tutorial|] about Basics of Java and Threads to know more about threads.
    N.B. And yes there are more articles and tutorials available but much of them targets the Java SE / EE, but if you want to read them here is [another great one straight from SUN|] .
    Edited by: find_suvro@SDN on 7 Nov, 2008 12:00 PM

  • Syncing problem with AppleTV and HP w/ Windows Vista

    Vital Stats:
    HP Media Center PC
    Windows Vista Home Premium
    AppleTV 40GB Software Version 2.0.2 Wireless DHCP
    I have been trying to sync my Apple TV with iTunes and keep getting the error:
    The Apple TV "Downstairs Apple TV" is not responding.
    Check that any firewall software running on this computer has been set to allow communication on port 3689.
    I have done the obvious. I have checked the firewall software on my computer and have manually set the port as open and apparently when iTunes installs it also puts port information into the Windows Firewall. I have performed a factory reset on the Apple TV, reinstalled iTunes, checked my router and still it's a 'no go'.
    Any suggestions?

    Welcome to the  Discussion Forums.
    Check your router for port forward/NAT rules that may involve ports 5353 and 3689, check that you haven't got the tv isolated at the router also.
    Security software and file sharing applications may also be interfering with these ports take a look at any software on your PC that might be doing this.

  • Problem with drag and drop application windows from one workspace to another

    I work with multiple desktops (Spaces) and before I freely dragged the mouse a window from one space to another, now the mouse rests on the edge of space and the application does not become the next space. What am I doing wrong or where this option is set?

    After the publication of the problem has disappeared, the window is dragged. Miracle! )

  • I'm at the end of my tether with not being able to access itunes which I could do perfectly well before! Now my laptop won't even connect to the internet despite the connection at the hub being excellent! No problem with ipad and phone - only windows!

    I'm tired of this problem of not being able to access itunes on my laptop and now no internet access despite connection and strength being excellent. What are windows playing at? Worked perfectly well until recently. Very frustrating and time consuming!

    Just a few lines to assure you you are not alone regarding speed delivery. By no means.
    I'm on Infinity 2 with HH5 - was virtually guaranteed 63 d/l and told possibly even up to 78. My actual speeds are nearer 15 (yes 15!) to 28 d/l if I am lucky. I've played all the obligatory games of checking and posting and reviewing my HH stats - and of course wasting my time with India "help" customer services who are instructed to read from a script of inane generalities which are usually completely irrelevant and have no connection whatsoever with a user's Specific problem.
    It more often than not turns out that the automated monitoring system imposes a software called DLM = Digital Line Management = which (with the endless excuse of improving line stability) increases noise margins and drastically reduces speed. This can kick in pretty rapidly and can take at least 3 to 4 days to modify itself - if indeed at all!!! Usually an Openreach engineer visit is then needed - who will re-set the Profile to what it is you are supposed to be paying for ..... then of course it is totally possible that DLM will re-emerge and the same old cycle of troubles will have to be endured.
    We pay in good faith at the outset on the back of so many promises - only to be cynically let down and dismissed once signed up. It is quite wrong we have to continually argue our case to (try) to get anywhere and are always reminded that we are tied into contracts with expensive escape clauses - or that an engineer's visit is only free IF it is proved the fault is not inside your house - which it very rarely is! This is often more an Ordeal than a subscribed service. Superfast reliable Broadband in the UK ? Ha!

  • Problem with JNI and Tomcat in windows

    Hello guys...
    I have the following problem.
    I used Tomcat 4 and I have following ApiEncriptacion class, in package com.servipag.sts;
    package com.servipag.sts;
    class ApiEncriptacion
         public native String encripta(String texto, String ubicacionLlavePublica, String semilla);
         public native String desencripta(String texto, String ubicacionLlavePrivada);
    the LD_LIBRARY_PATH is set in following dir c:\tomcat\bice
    the dll this in the following path = c:\tomcat\bice\apisdark.dll
    I run Tomcat at the following way..
    C:\jdk1.4\bin\java.exe -jar -Djava.library.path="c:\tomcat\bice" -Duser.dir="C:\Tomcat" "C:\Tomcat\bin\bootstrap.jar" start
    but, still appear the error:
    java.lang.UnsatisfiedLinkError: encripta
         at com.servipag.sts.ApiEncriptacion.encripta(Native Method)
         at com.servipag.sts.ServiciosServiPagImpl.rescatarFirma(
         at com.servipag.sts.ServiciosServiPagImpl.pagarCuenta(
         at org.apache.jsp.SBCO_0005flogin_0005fbice_0005f4$jsp._jspService(SBCO_0005flogin_0005fbice_0005f4$
         at org.apache.jasper.runtime.HttpJspBase.service(
         at javax.servlet.http.HttpServlet.service(
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(
         at org.apache.jasper.servlet.JspServlet.service(
         at javax.servlet.http.HttpServlet.service(
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
         at org.apache.catalina.core.StandardWrapperValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.core.StandardPipeline.invoke(
         at org.apache.catalina.core.ContainerBase.invoke(
         at org.apache.catalina.core.StandardContextValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.valves.CertificatesValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.core.StandardPipeline.invoke(
         at org.apache.catalina.core.ContainerBase.invoke(
         at org.apache.catalina.core.StandardContext.invoke(
         at org.apache.catalina.core.StandardHostValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.valves.ErrorReportValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.valves.AccessLogValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.core.StandardPipeline.invoke(
         at org.apache.catalina.core.ContainerBase.invoke(
         at org.apache.catalina.core.StandardEngineValve.invoke(
         at org.apache.catalina.core.StandardPipeline.invokeNext(
         at org.apache.catalina.core.StandardPipeline.invoke(
         at org.apache.catalina.core.ContainerBase.invoke(
         at org.apache.catalina.connector.http.HttpProcessor.process(
    please help me
    Luis Navarro.

    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class ApiEncriptacion */
    #ifndef IncludedApiEncriptacion
    #define IncludedApiEncriptacion
    #ifdef __cplusplus
    extern "C" {
    * Class: ApiEncriptacion
    * Method: encripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_encripta
    (JNIEnv *, jobject, jstring, jstring, jstring);
    * Class: ApiEncriptacion
    * Method: desencripta
    * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_ApiEncriptacion_desencripta
    (JNIEnv *, jobject, jstring, jstring);
    #ifdef __cplusplus
    #include "jni.h"
    #include <stdio.h>
    #include "files.h"
    #include "hex.h"
    #include "rsa.h"
    #include "randpool.h"
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed);
    char RSAEncryptString(const char pubFilename, const char seed, const char message);
    char RSADecryptString(const char privFilename, const char *ciphertext);
    Java_ApiEncriptacion_encripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePublica, jstring semilla)
              char *ciphertext = RSAEncryptString(ubicacionLlavePublica, semilla, texto);
              delete [] ciphertext;
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
              return ("");
    Java_ApiEncriptacion_desencripta(JNIEnv *env, jobject obj, jstring texto, jstring ubicacionLlavePrivada)
              char *decrypted = RSADecryptString(ubicacionLlavePrivada, texto);
         catch(CryptoPP::Exception &e)
              return ("");
         catch(std::exception &e)
              return ("");
              return ("");
    int main()
    void GenerateRSAKey(unsigned int keyLength, const char privFilename, const char pubFilename, const char *seed)
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         RSAES_OAEP_SHA_Decryptor priv(randPool, keyLength);
         HexEncoder privFile(new FileSink(privFilename));
         RSAES_OAEP_SHA_Encryptor pub(priv);
         HexEncoder pubFile(new FileSink(pubFilename));
    char RSAEncryptString(const char pubFilename, const char seed, const char message)
         FileSource pubFile(pubFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Encryptor pub(pubFile);
         if (strlen(message) > pub.MaxPlainTextLength())
              cerr << "message too long for this key\n";
         RandomPool randPool;
         randPool.Put((byte *)seed, strlen(seed));
         char outstr = new char[2pub.CipherTextLength()+1];
         pub.Encrypt(randPool, (byte *)message, strlen(message), (byte *)outstr);
         HexEncoder hexEncoder;
         hexEncoder.Put((byte *)outstr, pub.CipherTextLength());
         hexEncoder.Get((byte *)outstr, 2*pub.CipherTextLength());
         outstr[2*pub.CipherTextLength()] = 0;
         return outstr;
    char RSADecryptString(const char privFilename, const char *ciphertext)
         FileSource privFile(privFilename, true, new HexDecoder);
         RSAES_OAEP_SHA_Decryptor priv(privFile);
         HexDecoder hexDecoder;
         hexDecoder.Put((byte *)ciphertext, strlen(ciphertext));
         SecByteBlock buf(priv.CipherTextLength());
         hexDecoder.Get(buf, priv.CipherTextLength());
         char *outstr = new char[priv.MaxPlainTextLength()+1];
         unsigned messageLength = priv.Decrypt(buf, (byte *)outstr);
         outstr[messageLength] = 0;
         return outstr;

Maybe you are looking for

  • Select more than one photo for an mms upload

    I am trying to send more than one photo (by mms) to [email protected]  It will only let me select one at a time to upload.  I know how to select more than one (capital button), but it does not work.  any body know how to select more than one photo to

  • To all the people waiting for the gingerbread update.....

    !!!IT'S NOT GOING TO HAPPEN!!!! (and i mean this in the nicest way....) Here are a few reasons to support this theory: 1. All models of the Droid Incredible are no longer being produced by HTC, they have stopped production 2.If your android incredibl

  • Execute EXP command in SQL or PL/SQL window

    Hi, Sorry Regards Sanjit Edited by: userSanjit on Jun 2, 2009 2:47 PM

  • TS1424 Downloaded a song that won't play

    I've downloaded 20 songs in one day. 5 of the songs will only play for 20 seconds before there is either silence or it automatically goes on to the next song. What is goin on?!!

  • Cleaning Up "Untitled Audio" Files

    I used to not name a project until after i'd recorded multipe tracks, so over the months i've accumulated a lot of "untitled audio" tracks numbered from 1-300 or so. Is there any way to see which files were used for which song so I can properly renam