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.
Related
Is there a way to run a Java Applet in node.js, at server side?
It may sound crazy, but I am looking for a way to run a third party java applet on my node.js app server.
It is used to do a weird calculation that I am not willing to migrate to JavaScript code. Is this possible in any way? Any suggestions? I am in need to send the result of this calculation as a web page to the user, based on a request param.
I was initially thinking of how can I communicate between node.js and an Java Applet running standalone. Googled a bit but no success at all. Can someone suggest how to better google for it or point some good resources???
Using JNI will not help you as applets will not run in a headless environment. Applets are directly dependant on AWT so require a GUI environment to run.
Presuming that the license issues of the applet allow you to reuse the code, then my solution is to decompile the classes for the applet and use the generated java to create a normal java class with main that will run the desired calculations and return the result.
Unless the code is obfuscated, it's relatively simple to understand the decompiled code and should be relatively painless to adapt for what you wish to do.
Once you have your java code working from the command line you can then use the node-java project to call the java code from node.js and get your result.
I have a problem relating my web project.
Previously when my professor ask me on doing a online judge application, I chose to implement it using php rather than Java servlet, as I thought java servlet quite complicated.
Then problem comes. For the online judge, I have to use a backend java program on the server to do the processing of user submitted codes. That is, each time a user submits something, php would call the java virtual machine and invokes the java application. However, to invoke the java application, my own way now is to use command line
popen("start java -jar \"$FILE_ROOT/OnlineJudge.jar\"", "r");
This works fine, but considering loading of java virtual machine, it is actually very slow and error prone. So I was wondering if there is any better ways for PHP to invoke local java programs on the server. Because later I found I still need to invoke more java from php.
Any idea would be appreciated. Thanks.
have you considered php-java bridge, this is quite useful, it uses XML to communicate between php and java.
You'll need to start the JVM once and the bridge component will help with communication.
here are some examples, here you can find a simple example to connect php and java
Depending on how the java application is written, it likely wouldn't be too hard to convert it to a servlet. Once it is a servlet, run it under jetty or tomcat, and then just have your php connect to it via CURL and put/get data from the servlet.
Java servlets are fairly simple. If you are using an external framework like Spring it becomes even easier, but if not, you just need to extend javax.servlet.http.HttpServlet, and then configure it in your web.xml.
It's a bit of a hack, but shouldn't take you too long to accomplish.
Also take a look at the exec for command line executions. I used it to shut down my computer after doing an extensively long task well into the night.
I have a C++ application that uses the Java Native Interface and creates a JVM in order to execute Java code. How can I debug this Java code while it is being executed within my C++ application? I have all the relevant Java source code, and I'd like to set breakpoints and watch object data within Eclipse.
I've heard of JDPA and JDWP as tools to accomplish this, but I have no idea about the specific steps. Is there a tutorial for this kind of debugging situation?
This EclipseZone article is a few years old but I think the basic workflow is the same.
Enable remote debugging when starting your JVM within JNI (using the JavaVMInitArgs.JavaVMOption array, see the spec on JNI_CreateJavaVM).
You should then be able to follow the EclipseZone steps using localhost as your remote site.
You could run jdb.exe from your c++ application. Here is a nice article that can set you in the right direction.
http://www.javaworld.com/javaworld/javaqa/2000-06/04-qa-0623-jdb.html
Cheers!
I have a situation. A device connected to PC(client side) via COM. The vendor provide me a dll to exchange data with the device. I would like to create a java web-app to collect data from many devices(connected to backend through PCs). So how can I call dll from a servlet? Thanks in advanced!
The straight-forward solution is using JNI or JNA. You should learn appropriate tutorial from Oracle to learn how to do this.
But probably you can do it easier. If for example this DLL is ActiveX you can create script (VBScript or JScript) and then run it from java using utility named cscript. Other possibility if this DLL already knows to run as a stand alone application (or you have separate command line app that runs this DLL and provides you CLI.). In this case I'd recommend you to use it unless you have serious performance constraints. It is much easier to run command line application from java than coding JNI.
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.