Windows 8.1 Enterprise 64 bit running java jdk 1.8.0_60 gives a named pipe open error 'The system cannot find the file specified'

Hi

Not sure if this is a windows or java problem, so posted this on the Oracle Java site as well, but really grateful if anyone can help. On Windows 8.1 Enterprise 64 bit the example below works OK with java 1.7 but errors with java 1.8. On previous windows versions both versions of java appear to work OK.

Created a simple example to reproduce the problem:

Windows 8.1 Enterprise 64 bit running on an Oracle Virtual Box, Visual Studio 2012 Professional, Eclipse Luna 32 bit, 32 bit java 7.65 and 32 bit java 8.45 installed.

Use Vis Studio to create a new C++ project configuration Win32, create a .cpp file and paste the following:

Please note: PIPENAME below is "{backslash}{backslash}{backslash}{backslash}.{backslash}{backslash}pipe{backslash}{backslash}UC_MENU_PIPE"

// PipeSample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <windows.h>
using namespace std;
#define       DEFAULTTIMEOUT 120
#define BUFSIZE 512
int main(int argc, const char **argv)
{
    wcout << "Creating an instance of a named pipe..." << endl;
    // Create a pipe to send data
                    HANDLE pipe = CreateNamedPipe(  L"PIPENAME", // name of the pipe
                                                                                PIPE_ACCESS_DUPLEX,
                                                                                PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
                                                                                1, // only allow 1 instance of this pipe
                                                                                BUFSIZE,
                                                                                BUFSIZE,
                                                                                DEFAULTTIMEOUT,
                                                                                &sa // use default security attributes
                                        );
    if (pipe == NULL || pipe == INVALID_HANDLE_VALUE) {
        wcout << "Failed to create outbound pipe instance.";
        system("pause");
        return 1;
    }
    wcout << "Waiting for a client to connect to the pipe..." << endl;
    // This call blocks until a client process connects to the pipe
    BOOL result = ConnectNamedPipe(pipe, NULL);
    if (!result) {
        wcout << "Failed to make connection on named pipe." << endl;
        // look up error code here using GetLastError()
        CloseHandle(pipe); // close the pipe
        system("pause");
        return 1;
    }
    wcout << "Sending data to pipe..." << endl;
    // This call blocks until a client process reads all the data
    const wchar_t *data = L"*** Hello Pipe World ***";
    DWORD numBytesWritten = 0;
    result = WriteFile(
        pipe, // handle to our outbound pipe
        data, // data to send
        wcslen(data) * sizeof(wchar_t), // length of data to send (bytes)
        &numBytesWritten, // will store actual amount of data sent
        NULL // not using overlapped IO
    );
    if (result) {
        wcout << "Number of bytes sent: " << numBytesWritten << endl;
    } else {
        wcout << "Failed to send data." << endl;
                                        int pipe_err = GetLastError();
                                        wcout << "GetLastError(): " << pipe_err << endl;
    }
    // Close the pipe (automatically disconnects client too)
    CloseHandle(pipe);
    wcout << "Done." << endl;
    system("pause");
    return 0;
}

Save and build to ensure no errors.

Create a new workbench in Java, set the Project properties to point Compiler and Build Path to jdk 8.45, add a new class called AppletTester and paste the following:

import java.io.File;
import java.io.RandomAccessFile;
import javax.swing.JApplet;
public final class AppletTester extends JApplet implements ISuperRequestFocus {

                    private static final long serialVersionUID = 1L;
                    {
                    try
                    {
                                        File pipe = new File("PIPENAME");
                                        RandomAccessFile rafile = new RandomAccessFile(pipe,"rwd");
                                        rafile.close();
                    }
                    catch(Exception e)
                    {
                                        e.printStackTrace();
                                        System.out.println("exception in run " + e);                                         
                    }
                    }
                    public void superRequestFocus() 
                    {
                                       super.requestFocus();                    
                    }
}

interface ISuperRequestFocus

{

                    public void superRequestFocus();
}


Save and Clean to ensure no problems.
Start the Vis Studio C++ pipe creator.
Start the AppletTester fails to connect. Terminate the Vis Studio C++ pipe creator.
Change AppletTester Properties Compiler and Build Path to jdk 7.65, Clean.
Start the Vis Studio C++ pipe creator.
Start the AppletTester connects OK.

September 8th, 2015 11:58am

Hi alanhar,

Thank you for your question.

By this error, we suggest you post this case to the following forum:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio 

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding. 

If there are any questions regarding this issue, please be free to let me know.

Best Regard,

Jim
Free Windows Admin Tool Kit Click here and download it now
September 10th, 2015 2:14am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics