Results 1 to 4 of 4
  1. #1
    rinza is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default program terminates itself and leave log file called hr_err_pid in desktop

    public class RunUSBControllerTest extends JFrame{

    /** Creates a new instance of RunUSBControllerTest */
    public RunUSBControllerTest() {
    Host host;
    try {
    host = HostFactory.getHost();
    host.addUSBListener(new ControllerUSBListener() {
    public void deviceAdded (Device dev)
    {
    System.out.println("added");
    }
    public void deviceRemoved(Device dev) {
    System.out.println("removed");
    }
    });
    } catch (IOException e) {
    e.printStackTrace();
    }
    setSize(100, 100);
    setLocationRelativeTo(this);
    setVisible(true);
    }
    public static void main(String[] args1) {
    RunUSBControllerTest test = new RunUSBControllerTest() ;
    test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
    }
    }

    here is the code.. when i run the window will appear and after i insert my pen drive the window will just disappear and leaves hr_err_pid log file.
    also showing following error in console:
    # A fatal error has been detected by the Java Runtime Environment:
    #
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00c69f04, pid=5052, tid=5328
    #
    # JRE version: 6.0_17-b04
    # Java VM: Java HotSpot(TM) Client VM (14.3-b01 mixed mode, sharing windows-x86 )
    # Problematic frame:
    # j usb.windows.Windows.getHostControllerName(Ljava/lang/StringLjava/lang/String;+0
    #
    # If you would like to submit a bug report, please visit:
    # HotSpot Virtual Machine Error Reporting Page
    pls help me?

  2. #2
    rinza is offline Member
    Join Date
    Jan 2010
    Posts
    4
    Rep Power
    0

    Default PS

    P.S I am using jusb API.

  3. #3
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: program terminates itself and leave log file called hr_err_pid in desktop

    Little late I assume, but as I really was pissed off by 2 hours of debugging, so I hope it is still ok to share the potential solution. I had the same problem and I wonder why none replied. The reason is that Windows.getHostControllerDevicePath(i) returns an invalid path if the library is not yet ready or initialized. A valid name starts with a backslash, so I included a simple check in the project within the method Watcher::scan() of the jUSB code:

    // Wait for usb initialization to finish
    try
    {
    do
    {
    Thread.sleep(50);
    sDevPath = Windows.getHostControllerDevicePath(0);
    if (Windows.debugWatcher) System.out.println("Waiting for USB valid device strings...");
    } while (!sDevPath.startsWith("\\"));
    }
    catch(Exception oException)
    {
    }

    This helped, even the 50ms would be enough, I suspect that for some reason either multicore or very fast systems have problems with the implementation as is. Just guessing though...



    The whole code snippet of the function:

    private void scan() throws IOException
    {
    String sDevPath;

    synchronized (busses)
    {
    // Wait for usb initialization to finish
    try
    {
    do
    {
    Thread.sleep(50);
    sDevPath = Windows.getHostControllerDevicePath(0);
    if (Windows.debugWatcher) System.out.println("Waiting for USB valid device strings...");
    } while (!sDevPath.startsWith("\\"));
    }
    catch(Exception oException)
    {
    }

    // what busses exists now?
    // look for all existing Host Controller on the Windows OS
    int i = 0;
    String hostControllerDevicePath;
    [.......]
    Last edited by Sierra; 03-12-2012 at 11:38 PM.

  4. #4
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: program terminates itself and leave log file called hr_err_pid in desktop

    As an additional issue I have found that if the native path to the jusb.dll is not set correctly for a subproject using the interface the waiting does never finish, though no error is thrown. This happens e.g. if you write a project using another project that implements the jusb interface (your project -> "jusb project" -> jusb.dll). You may set the path by clicking the properties of your project and then go to the references and there set the "native path" to the directory where the jusb.dll is located (usually the working "jusb project").

Similar Threads

  1. How to make Exe file of desktop application
    By rakesh_n_mehta in forum AWT / Swing
    Replies: 1
    Last Post: 12-12-2009, 01:27 PM
  2. Replies: 0
    Last Post: 09-22-2009, 07:15 PM
  3. Run program from desktop?
    By McChill in forum New To Java
    Replies: 3
    Last Post: 06-23-2009, 09:54 PM
  4. Application automatically terminates
    By PaulT in forum Eclipse
    Replies: 4
    Last Post: 03-18-2009, 05:02 PM
  5. launch a desktop icon program command
    By avaj987 in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 11:40 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •