Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If what bobince says is accurate and you cannot reliably get the data to java directly, one alternative solution would be to write a small "shim" program in another language (e.g. C, C++ or C#). </p> <p>The idea is that the program grabs the input as UNICODE, encodes it so that it's expressible using only ASCII characters (e.g. by using base64, or even something as simple as encoding every character as its numerical equivalent) and then assembles the command line argument to use and launches java itself using CreateProcess.</p> <p>Your Java code could "undo" the encoding, reconstructing the UNICODE name and proceeding to use it. It's a bit of a roundabout way and requires an extra component for your software, but it should work around the restriction detailed above, if indeed that is an actual restriction.</p> <p><em>Update</em>: This is the basic code for the shim program. It encodes input as a sequence of integers, separated by colons. It doesn't do much in the way of error checking and you might want to improve it slightly, but it should at least get you started and going in the right direction.</p> <p>You should grab Visual Studio Express (if you don't already have Visual Studio) and create a new Visual C++ project, choose "Win32" and select "Win32 Project". Choose "Win32 application". After the project is created, replace everything in the .cpp file that is displayed with this code:</p> <pre><code>#include "stdafx.h" #include &lt;string&gt; int APIENTRY _tWinMain(HINSTANCE, HINSTANCE, LPTSTR lpCmdLine, int) { std::string filename; while((lpCmdLine != NULL) &amp;&amp; (*lpCmdLine != 0)) { if(filename.length() != 0) filename.append(":"); char buf[32]; sprintf(buf, "%u", (unsigned int)(*lpCmdLine++)); filename.append(buf); } if(filename.length() == 0) return 0; PROCESS_INFORMATION pi; memset(&amp;pi, 0, sizeof(PROCESS_INFORMATION)); STARTUPINFOA si; memset(&amp;si, 0, sizeof(STARTUPINFOA)); si.cb = sizeof(STARTUPINFOA); char *buf = new char[filename.length() + 256]; // ensure that 256 is enough for your extra arguments! sprintf(buf, "java.exe -jar some.jar &lt;arguments1&gt; \"%s\" &lt;arguments2&gt;", filename.c_str()); // CHECKME: You hard-coded the path for java.exe here. While that may work on your system // is it guaranteed that it will work on every system? if(CreateProcessA("C:\\Program Files\\Java\\jre7\\bin\\java.exe", buf, NULL, NULL, TRUE, 0, NULL, NULL, &amp;si, &amp;pi)) { CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } delete[] buf; return 0; } </code></pre> <p>You should be able to figure the details on how to compile and so on fairly easily.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload