I'd like to make an Online Game with Android.
I'm planning to make Server with IOCP model via C++. This should work fine, the problem is the client.
IOCP client example in C++ uses WSASyncselect or WSAEventSelect.
I couldn't find any Java examples that same work like async socket.
Questions:
Is there anything like WSASyncselect() in Java?
If not that, how could i do it?
The JDK 7 Windows implementation of the Java 7 "NIO.2" classes
AsynchronousSocketChannel
AsynchronousServerSocketChannel
AsynchronousFileChannel
call the WSA[...] functions of the Windows "Overlapped IO" API behind the scenes.
For more in-depth information check out the OpenJDK repository folders containing the implementation .java sources along with their corresponding .c native sources and JNI bindings
.
Related
I'm using JACOB in order to write message to a COM interface.
Dispatch dispatch = new Dispatch("<Interface Name>");
Variant response = Dispatch.call(dispatch, <DISPID>, message);
This works perfectly on localhost. But how can I use JACOB api to call interface on some other Machine/IP Address
JACOB seems to be unable to remotely access (DCOM call).
JACOB Project mailing-list FAQ
Can I call COM component across machines or operating systems?
The answer to this question is No. The way jacob is implemented is using JNI and a c++ DLL designed for the windows platform. COM is a binary standard defined by Microsoft as it hasn’t been ported over (as far as I know) to any other platforms yet. Jacob is only a java bridge for COM which defines how components talk to each other when they are on the same machine. The DCOM standard defines how components communicate across networks, but Jacob has no support for DCOM.
Solutions:
Commercial products, like J-Integra support the DCOM protocol natively.
Use RMI. Make a wrapper for the Jacob classes, and RMI'ify it. It actually works, but the Jacob lead didn't want to make the classes implement serializable, making the whole operation slightly difficult.
Use Web Services. Expose the stuff you'd like to have as a Web Service, and use SOAP and snacks on the Java side to access it.
Alternatively, it may be useful if the locally working COM object supports remote access internally.
It seems like the following article.
Jacob connect to Remote Computer for WMI support
ADODB Recordset Example
The JACOB Project: A JAva-COM Bridge
Downloads
The JACOB binary distribution (jacobBin_XX.zip) includes:
jacob.jar: a JAR file for the java classes which you must add to your CLASSPATH. The package names replace com.ms with com.jacob (for example com.ms.com.Variant maps to com.jacob.com.Variant.
jacob.dll: a small Win32 DLL which you must add to your PATH.
samples: provided in Java source and compiled form to demonstrate various features of the product. In particular, a set of wrapper classes for Microsoft® ADO are provided as samples.
The source code is available in the JACOB source distribution (jacobSrc_XX.zip), which includes both the Java and C++ code. The source distribution is a superset of the binary one, so you don't need both.
Others seem to have other libraries, not JACOB.
A pure Java DCOM Bridge with j-interop
j-interop/j-interop/src/readme.htm
In Addition:
Similarly, it can not be called between computers connected via LAN.
Also, it is not possible to call local COM objects remotely with VC ++ or .NET language.
The workaround is to create a proxy application to call the local COM object on the remote computer.
Design the main application and the proxy application arbitrarily so that they can communicate with each other using a socket or other means.
I have a .NET Core (console) app that I would like for a Java app to depend on. Essentially I would like to be able for the Java app to invoke a multi variable method in the .NET Core app and then pass the result back to the Java app. It would be nice if the .NET Core app could be embedded in the Java app. I have previously seen .NET Framework specific solutions to this problem, but since this would only be relevant on Windows, I would like a solution that also works on Linux.
In the past there were some technologies such as IKVM.NET and COM Interop wrappers but the former is defunct and the latter probably wouldn't work on Linux.
Since you own the .net core code, I would take a more modern microservice approach. I would design the .net core app to be a REST API running as a console app listening on a port. I'd have the Java application spin up the console app, invoke the methods passing JSON back and forth and then spit it down when complete.
From my actual knowledge this nuget package JCOBridge is able to do what you are asking for.
Until now it supports linux for x64 architecture.
I tried the templates available on Templates and them works on my Ubuntu 18.04. The same templates works on Windows.
Is it possible to call a java pgm that is hosted on my ibmi from the pc?
I want to create a java program on my pc. The program should create a connection to my ibmi and call a java program hosted on my machine.
After searching in the web i try to find a solution in this forum.
is that possible?
what are the preferences that make that ?
edit
the java program on my ibmi should call a rpg/cobol program to grab some data and return them to the calling java on my pc.
bye jogi
Take a look at the JT400 project...
The IBM Toolbox for Java is a library of Java classes supporting the client/server and internet programming models to a system running IBM i (or i5/OS or OS/400). The classes can be used by Java applets, servlets, and applications to easily access IBM i data and resources.
Charles is right. JT400 is the way to go.
Here is a functional example.
Please provide some feedback if you run in trouble.
May I suggest looking at the answer to the following Stack Overflow post?
Accessing RPG on iSeries from Java
Depending on the situation, it might make more sense to call the RPG program directly from your PC's Java program. Otherwise, execute the CL Java command:
JAVA CLASS(my.java.class) PARM('a' 'b' 'c') CLASSPATH('/path/to/jarFile.jar') using the CommandCall class as described in the above mentioned post.
I need to use the logic contained in some java classes. I found JNI, but that project seems not updated recently.
Is there a way to use it in a Delphi native application? I use Delphi 2009.
A newer solution than JNI is JNA, which also supports callbacks from (Delphi) DLLs. I found it easy to use.
You could try j-interop.
The technique I should adopt is to build a COM wrapper of java business logic, and using this COM server from delphi throught interoperability.
Delphi can build a type library of a COM server, and you could istantiate the com server using this typelibrary. Type library is simply a wrapper of the server, exposing its interface to be used by delphi code.
The key to communicating with different platform softwares is called "interoperability".
You can find this also in .net versus win32. Tipically delphi code is win32 (exe or dll), and you can build communication protocol between delphi objects and .net assemblies or java bytecode using interoperability solutions.
With Java 6, it takes only a few lines of code to write a standalone web service server which then can be invoked from Delphi.
small step-by-step tutorial, using the free NetBeans IDE and Delphi:
Delphi and Java Integration using Web Services
more xamples:
http://www.theserverside.de/webservice-in-java/
http://www.torsten-horn.de/techdocs/jee-jax-ws.htm#Minimaler-Webservice
Embed the VM in the native code. This worked for me.
An example with c can be found here. http://java.sun.com/docs/books/jni/html/invoke.html
I very much doubt it. Delphi Code gets compiled into an executable while Java code is executed by a Virtual Machine. So unless you launch a complete Virtual Machine inside Delphi code I see no way to easily include the logics.
I want to call Java from PHP 5.2, running either on a webserver or from a command line script.
From PHP 4, this seems to be simple, and just involves installing the PECL Java extension.
Example code from the PHP 4 extension:
<?php
// get instance of Java class java.lang.System in PHP
$system = new Java('java.lang.System');
// demonstrate property access
echo 'Java version=' . $system->getProperty('java.version') . '<br />';
?>
However, this extension doesn't exist on PHP 5.
What is the closest alternative for PHP 5?
edit:
Really I'm looking for an interface similar to either a C PHP extension or to that provided by the PHP 4 Java extension. The Java program is fairly small and only needs to retain a small amount of state between calls and doesn't need to run asynchronously. The PHP script would only be running a small number of instances simultaneously.
This would also need to be deployed to multiple machines (running Ubuntu 9.x and Debian Lenny), so it should be simple to install.
This project seems to be a good bet: http://php-java-bridge.sourceforge.net/pjb/
Since you want to keep state at the java site I'd either use a java process that listens on a plain socket or use a simple embedded webserver (winstone or jetty) if you are more fluent writing servlets. Some other possibilities are listed at this related question: What is the best approach for IPC between Java and C++?
Now quite what you asked for, but you could have a look at Caucho's Resin, and in particular their Quercus which is a 100% Java implementation of PHP, it allows integration of Java and PHP.
I have a project that uses a Java program to fetch some data. It's quite simple, but I found that
$java_command="cd /var/java_dir && java my_java_program $myparam1 $myparam2";
$result=exec($java_command,$output,$return_code);
works just fine.
Zend Server also has a built-in daemon allowing you to access Java functionality from within PHP. It works right out of the box.