Problem opening device from Java on Windows XP

Hi,
I am having trouble opening the TUN device (it is a virtual network device developed by the OpenVPN project - http://openvpn.net) from Java on Windows.
I found from the registry that the key for the device on my machine is
{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.
From elsewhere on the web, I found that on Windows this device can be
addressed as \\.\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap
I then wrote up a short C code,
char *tun_dev_name = "\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap";
FILE *f = fopen(tun_dev_name, "rw");
fclose(f);
HANDLE h = CreateFile(tun_dev_name, GENERIC_WRITE | GENERIC_READ, 0, 0, \
OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0);
CloseHandle(h);In the above code, the FILE* returned is non-NULL and the HANDLE returned is positive.
However, when I try to do the same in Java using the code below,
String tun_dev_name =
new String("\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap");
RandomAccessFile raf = new RandomAccessFile(tun_dev_name, "rw");
[]/code]
a "java.io.IOException: Invalid argument" is thrown. The same exception is thrown when I try to open either FileInputStream or FileOutputStream instead of RandomAccessFile.
In fact, when I invoke the above C code as a native method from within Java,
though a valid HANDLE is still returned, the FILE* returned is now NULL. I
have tried giving all permissions to my codebase using Java's policytool, but that didn't help. BTW, I ran all this code on Windows XP from cygwin.
Clearly this problem isn't with OpenVPN because I'm able to open the device using both fopen and CreateFile from C. Please let me know if one of you knows what the problem could be and what I need to do to fix it. In case, this is not the right forum for this question, kindly let me know which other forum I should pose this question on.
Thanks!
Harsha                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

I am sorry but looks like somehow some text got missed out from my message.
After the C code and before the Java code, I had intended to mention that when that C code is compiled and run independently, both the fopen and CreateFile calls work fine, with a non-NULL FILE* and a valid HANDLE being returned, respectively.
And as I have already mentioned, when I invoke the C code as a native method from within Java, the CreateFile still works but the fopen fails returning NULL.
Sorry for missing that out. Hope somebody will be able to help me out.
Thanks!
Harsha

Similar Messages

  • Open URL from Java in a new browser tab

    Hi OTN,
    Surprisingly can't find the implimintation.
    In an ADF managed bean I retrieve String url. I need to open a new browser tab with this url.
    Found this thread Open a url in a new window in the backing bean which shows using javascript "service.addScript(facesContext, "window.open(http://www.google.coml)");".
    But in my case in doesn't work. The code is executed, but nothing happens. Maybe because the bean is called from a taskflow inline popup.
    ADF 11.1.1.4
    Thanks.

    Well, I'm afraid that is not an option.
    The goButton is in a table row. There are lots of rows so if I use EL for Destination attribute the URL would be retrieved for each of rows.
    The method of URL retreiving is heavyweight operation which includes calling plsql functions, working with strings and others. So if I do it for each table row my application hungs and then I receive an exception of CPU usage.
    That's why I switched to normal commandButton witch actionListener which retrieves url on click - only once. So I need to open URL from Java.

  • Problems opening .pdf files created in Windows in MAC

    My clients that are using Macs are having problems opening password protected PDFs that I created in Windows. Any suggestions?

    Are your clients using Adobe Reader on Mac, or the built-in Mac OS Preview?  Preview does NOT support the full PDF standard :(.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Mon, 26 Sep 2011 15:04:18 -0700
    To: Leonard Rosenthol <[email protected]<mailto:[email protected]>>
    Subject: Problems opening .pdf files created in Windows in MAC
    Problems opening .pdf files created in Windows in MAC
    created by Hollcy<http://forums.adobe.com/people/Hollcy> in PDF Language and Specifications - View the full discussion<http://forums.adobe.com/message/3939175#3939175

  • Unable to open a seperate java console window with javascript:window.open()

    Hi All,
    I am opening a new window using javascript:window.open() function by clicking an hyperlink in a html document. In this new windows I am trying to load an applet. Only for the first time a java console window is displayed in windows system tray . How can I open a different java console window each time I open a new window ? Basically I want to run each applet in its own JVM and it seems that each applet loaded in new window is using the same JVM and hence only one java console window is seen in my system tray.
    Please help ...
    Thanks & Regards,
    Ravi.

    Hi,
    We are currently facing this exact issue. Did you ever find a resolution?
    Any input would be appreciated.
    Thanks,

  • Open Word From Java

    Hi all,
    Can we open word from java.
    It is possible from VB to do it, bit is it possible from Java.
    Thanks in advance for your help.
    Best regards.
    Saadi MONLA

    Probably have to do it using Runtime.exec() and call the word exe in the seperate process.
    Note that word will be opened in a seperate OS thread and you will not be able to refer to it from your Java Application.

  • I am having problemes opening attachments from adobe reader.  I'm getting error 1606 (an internal error).  Plz HELP!

    I am having problems opening attachments from adobe reader.  I'm getting error 1606 (internal error).  PLZ HELP!

    <http://kb2.adobe.com/cps/402/kb402867.html> might help.

  • HT4113 my iphone screen is broken ,how can i open device from laptop ??

    my iphone screen is broken ,how can i open device from laptop ??
    plase ,help me what can i do to fix this device   & the VGA is not work good i think there is short in VGA ,please help me  what can i do....

    Connect the phone to iTunes on your computer, right click on it in the device list and choose "backup". This will save your data and settings.
    Purchases can be transferred by choosing "transfer purchases".
    After that import photos or videos to your computer.
    You can use the backup again to restore the phone after it has been serviced.
    iOS: Back up and restore your iOS device with iCloud or iTunes

  • Entourage open from dock opens a new message screen. If I open it from the application window it open to my inbox as normal. Just since upgrading to Mavericks.

    Since upgrading to Mavericks, when I open Entourage from the dock it opens the program and opens a new message window. Very annoying. If I open it from the application folder it opens to my inbox like it always has. Any ideas?
    Thanks
    Dave

    the problem has been solved for me following the process :
    1 -close entourage
    2 - start and follow the complete reconstruction of the entourage database ;
    3 - in the "entourage" menu, disable "office reminds" or "office recall" (i don't know the exact name because my entourage is in french)
    For me it has worked. when i click on the dock entourage shortcut it opens without showing the new message windows at start.

  • Problems opening PDFs from SharePoint 2007 with Acrobat X Pro

    We are currently migrating to Windows 7 x86, Acrobat X Pro, and Office Pro Plus 2010 SP1. Our old setup is Windows XP, Acrobat 8 Pro, and Office 2007. We are using SharePoint 2007. On our older machines, we are able to open and edit PDFs without any problems. However, on our newer machines with Acrobat X, we get this error whenever we open a PDF for editing:
    The document could not be opened for editing. A Windows SharePoint Services compatible application could not be found to edit the document.
    All of our XP users can open and edit documents without any problems--only our newly migrated Windows 7 users are unable to edit these documents. Is there a setting that I need to adjust in Acrobat X? I don't recall seeing any Acrobat X specific options in SharePoint configuration. Thanks!
    EDIT: I was able to open and edit a PDF document using the following steps:
    1. Click drop-down menu next to document and select "Check Out."
    2. In the check-out dialog box, check "Use my local drafts folder." Click OK.
    3. Back in SharePoint, click on document to open--click OK to message warning about malicious files.
    4. Edit document, then click Save button. Close Acrobat.
    5. Back in SharePoint, click drop-down menu next to document and select "Check In."
    6. Confirm the check-in.
    7. Redirected back to document library and the modified date and by fields are updated.
    This seems like an awful amount of steps. Is there a way to make this function the same when a user edits a Word or Excel document?
    Message was edited by: jprateragg
    Added info under EDIT.

    In Acrobat X, SharePoint Integration has been added which allows users to check-out/check-in the document from within Acrobat. Clicking the file from document library in Internet Explorer opens the file in Acrobat. The configuration that needs to be done on the SharePoint server is explained in the following KB article in section 11.1.
    http://kb2.adobe.com/cps/837/cpsid_83709/attachments/Acrobat_Enterprise_Administration.pdf
    Please try these and let us know if you face any problems after this.

  • Problem opening excel file in new window

    Hi,
    I have a JSF application that sends an Excel file back to the user.
    My backing bean has a method that uses POI to generate the excel file and then write it to the servlet response.
    This works fine if I call the method from a command button, but this displays the file in the current browser window, whereas I want to open the file in a new window.
    I added an onclick javascript call to a command button which does a window.open() to open a jsp in a new window. The jsp contains an empty view, as I'm using an on-load phase listener to make the call to my backing bean method which should send the excel file when the file opens.
    However, when the window opens, I get an IE error message saying 'Could not open xxx.faces', and then an excel error message saying 'Could not open xxx.xls. This may be because the file does not exist, or the file is already open etc etc'
    However, I found that if the popup window goes through a servlet (which just forwards to the jsp page) instead of going to the jsp directly, it works like a charm.
    Any ideas or suggestions on how to fix this would be very much appreciated. If I can't fix it I'll just stick with the servlet approach, although it just seems a bit messy.
    (I'm using IE6 SP2, tomcat 5.5 btw)
    Cheers,
    Stuart

    I'm doing a similar thing, but I use commandLink to lauch the window. CommandLink has the "target" attribute that I set to _blank.  As you would expect, that opens up the page in the new window.                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problems Accessing VARRAY from Java

    Hi,
    I am calling a stored procedure with IN parameters as VARRAYS from Java application.
    There are two schemas in the database. One main schema, say 'MAIN_SCHEMA' which contains all the table,VARRAYS,packages etc. There are public synonyms for all the database object including VARRAYS in this schema. The java application uses a connection pool created using another user say 'ADMIN'. This user has been granted priviliges for acccessing all the objects in the 'MAIN_SCHEMA'. For the VARRAYS we have created public synonyms and granted EXECUTE for ADMIN.
    However when I try to execute the stored procedure from java , I get an SQLException("invalid name pattern: ADMIN.UIDARRAY")
    I solved the problem temporarily by prefixing the main schema name to the name of the VARRAY. The sample code I have used is as below. but I am not sure if this is the correct way of doing it. I do not understand why we have to prefix the schema name if we have priviliges and public synonyms on the object.
    public void setPendingForfeituresUids(java.util.List pendingForfeituresUids) throws DAOException{
    try{
    ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor(
    "MAIN_SCHEMA.UIDARRAY", con);
    array = new ARRAY(descriptor, con, pendingForfeituresUids.toArray());
    if(array == null){
    stmt.setNull(3,java.sql.Types.ARRAY);
    }else{
    stmt.setArray(3, array);
    }catch(SQLException e){
    closeStatement();
    releaseLobWrappers();
    throw new DAOException(e);
    Database and Drivers used
    I am using Oracle 9.2.0.1.0, Weblogic 8.1, Oracle Jdbc thin driver for 9.2 that comes bundled with weblogic (ojdbc14.jar)
    Any help on this is welcome.
    Thanks,
    Sunil

    Hi Sunil,
    I was wondering if you had any solution to the problem you listed.
    We are also facing a similar problem and is reported to oracle. Its a Bug as per oracle.
    Any help in getting this resolved is appreciated.
    Thanks,
    Sandip
    [email protected]

  • Executing a dos command from java in windows nt

    i need to execute the
    " net send"
    command from the command line in windows nt, from within my java program... is there any way that i can execute cmommands in the dos command shell? or rather, does anybody know a way i can send a message ( in windows ) from java, from one computer to another over the lan?? I cannot have a java programming running on all the other computers, so i cannot make my program serve, it must just send the messges using a lan command....
    (the net send command just sends a message in the form of a pop up box on the receiver's screeen)
    thanks a bunch guys!!!
    Thanks a bunch guys!!!!

    you can do that with exec() in Runtime.
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command here);but before you do that you need to read this:
    http://www.javaworld.com/jw-12-2000/jw-1229-traps.html
    hth
    partha

  • Problems opening attachments from outlook

    This week I have been unable to open attachments from Outlook 2010. I use Firefox as my browser and for some reason when I click on an attachment it is downloaded into Firefox. This has only just started to happen. If I try to open a PDF document I would
    expect it to just open as a PDF rather than a Firefox download. How can I resolve this issue?

    Hi Tweek,
    Might be you are working with disabled attachment preview option. Follow the given path and turn on it: 
    File >> Options >> Trust Center >> Trust Center Settings (under Microsoft Outlook Trust Center) >> Attachment Handling
    If the above solution does not help, then change the default program for opening attachment. Make a right click on the PDF Document and select
    “Open With” option. Choose the default program and set it to as
    “Always the selected program to open this kind of file”.
    Source:
    http://office.microsoft.com/en-in/outlook-help/preview-attachments-HA010355566.aspx
    Feel free to response back for further response!!!
    Note: Make sure that Adobe Acrobat should be installed in your machine. 
    Thanks
    Clark Kent

  • Jintegra problem - accessing Matlab from Java??

    Hi:
    Sorry if this post doesn't belong here!!
    I am accessing Matlab from JAVA using JIntegra for COM. I tried running the example in their website.
    (http://j-integra.intrinsyc.com/support/com/doc/other_examples/Matlab.htm)
    I have also posted the example below. I am using their trial version and have included all the jars as said. I get the an unexpected output (all zero's) for reading a variable in the matlab workspace. I don't understand why I get this. Can anyone let me know if this runs for you??
    Thanks
    Pavan
    Example code from Jintegra website:
    public class MatlabExample {
    public static void main(java.lang.String[] args) throws Exception {
    try {
    // DCOM authentication: Make sure NT Domain, NT User, NT Password are valid credentials.
    // Uncomment this line if MatlabExample.java remotely accesses MATLAB :
    // com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "NT USER", "NT PASSWORD");
    // Create the MATLAB object
    // Specify host name or IP address of MATLAB machine as parameter if
    // MatlabExample.java remotely accesses MATLAB.
    // mlapp.MLApp mlApp = new mlapp.MLApp("123.456.789.0");
    mlapp.MLApp mlApp = new mlapp.MLApp();
    String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]");
    System.out.println("Execute result is " + result);
    double mreal[][] = new double[2][4];
    double mimage[] = new double[0];
    mlApp.getFullMatrix("a", "base", new Object[]{mreal}, new Object[]{mimage});
    for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 4; j++) {
    System.out.println(mreal[i][j]);
    } finally {
    com.linar.jintegra.Cleaner.releaseAll();
    }

    ......How are you declaring the class in your JSP? ... are you instantiating it as a bean using the useBean tag, or just instantiating it in your code like normal.
    Maybe you could post the relevant JSP code too?
    Hello again,
    Only the last string is populating after the file has be tokenized. What I'll like to accomplish is passing the very first string in the file. I did not get too far in the JSP file setup because the code is still in it's testing stage, but any help will be highly appreciated.
    Here is the JSP code
    <%@page import="dev.*" %>
    <%@page session="true" language="java" import="java.io.*" %>
    <jsp:useBean id="wagerhist" scope="request" class="dev.RoundDetail2" />
    <html>
    <head>
    <title>Round Detail</title>
    <body>
      <table width="530" bordercolor="#000000" valign="top">
        <tr>
              <td align="left"  width="19%">Game ID<%=wagerhist.string_gameID%></td>
              <td align="left"  width="30%">  </td>
              <td align="left"  width="20%">card1</td>
              <td align="left"  width="31%">  </td>
            </tr>
      </table>
    </body>
    </html>

  • Microsoft Word (2013) is Flaky When Opening Files from OneDrive (thru Windows Expolorer)

    A lot of MS Word files (saved as .docx) on OneDrive do not open the first time.  Word often hangs when opening.  We are using Windows 7 and this happens on multiple computers.  We have tried to repair/reinstall MS Office 2013 but this does
    not help.
    Are there any fixes that we can try?

    Hi,
    Does this only happen to Word documents? What about other type of Office application files?
    What do you mean by "do not open the first time"? Will it usually open when you try it once more?
    Please first check the event logs and see if there is anything useful recorded there about this issue.
    If you would like us to help analyze the logs, you can send the log file to this email account:
    [email protected] and inform us here (the email subject should be the link of this thread).
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

Maybe you are looking for

  • Can't acces AFP shares on PPC's on specific server

    We have a naughty problem at the office for accessing shared folders . We use G5 Xserve + Xraid serving home access to 12 macs. Our problem started when we updated all machines to 10.5.2 (nor did we have a problem with 10.5.1 or with 10.5.0). All mac

  • CS4 "Save as Adobe PDF" not working in Mountain Lion

    CS4 Save as Adobe PDF not working in Mountain Lion Just bought a new Mac with mountain lion, installed CS4 design premium twice trying to fix this. When you go to "print" then "Save as Adobe PDF" the process fails with a pop-up saying "An error occur

  • Error while dragging cube measures on powerview

    Hello! I'm trying to get started with PowerView in SharePoint 2013 but i'm facing a little problem. I'm trying to connect to a AnalysisServices (Multidimensional) instance, version 11.0.3373.0 on SQL Server 2012 SP1 CU5. In PowerView i can explore th

  • Array problem

    Small question about arrays: See attatched problem.vi. How can I add the values to the array, not only change the value at index 0 each time I press the button. Attachments: problem.vi ‏11 KB

  • How do I back-up and replace my hard drive that has crashed on a Pavilion a350n with XP?

    HP Pavilion Desktop a350n with Windows XP. System went through a CHKDSK scan, had a bunch of errors, then when it was done checking, a American Megatrends screen came up with status and at bottom says "Master hard disk: S.M.A.R.T. Status: BAD, Press