How to call jar file from c# [duplicate] - java

This question already has answers here:
Execute Jar file from C sharp code and get return value
(2 answers)
Closed 7 years ago.
I have a c# application and I have a .jar file that I have created. I want to call from c# application, my jar file, I want to call a method in the jar file. I try to use JNI but I can't call jar file.
There is a mode to do this?

Your main problem is the lanuage incomaptabilities
As far as i understand there is no direct way that Java (jar) and c# assembles can talk to each other.
Question is what does the jar file do ? and can the same be done using c#
If not then you are going to have to create a java application using somethign like Netbeans to act as a kind of middle man
Then when the c# application does a function call the call gets serialised into a file
The java app should then look for the file (in a thread or something) pulling the data and writing the response data to the file
While asp.net looks for changes in the file and pulls the data back from the file once java has written
There are other options such as web service and TCP IP socket server to communicate
But Long story short there is no clear cut way as far as i am aware of that there is not clear cut way of making java and .net talk to each other .
A quick google search did bring up http://www.ikvm.net/userguide/tutorial.html[^] which seems to be promising.
Hope this helps

Related

How to read console output from Grails [duplicate]

This question already has answers here:
How to read console ouput
(2 answers)
Closed 8 years ago.
My grails app has an external java library which I developed. I want my grails app to be able to display my java library system.out statements (console output). How do I go about doing that?
I would rather not have to write it out to a file then read it in grails. There must be a better way of doing this.
**I want grails to display these to a text box as the happen(In a browser while its running(so the user can see))
Afer trying several of my own ways I have to settle for this way which I will post here. Thanks #Shaunak for your help and understanding.
**How I solved it.
In my java library I created a global class which all the System.outs will be wrote to
writeSouts(String sout){
//store here in a global string and keep appending to it as needs be
}
Then in grails constantly call the java library method. and using Ajax write it out to the browser window.
Hope this helps anyone in the future who encounters the same problem.
Also it is not for testing but an integral part of my web app so that the user of the web app can was the java library is doing in the background.
Without much details on how exactly you are invoking the Java Library, I will assume here that it is just some code that writes to console, and you want to invoke and read it from inside Grails controller and send it back to HTML. Here's what I would suggest. Instead of including the Java Code as a library, create a command line utility out of it.
So your java program will be invoked for testing like so,
java MyLib -arg1 -arg2
This will should out put something like this on the command line:
> This is my nice output
Now to to invoke and read this from grails, you can use Groovy's External Process Management
and do something like this to invoke and read the output:
def process = "java MyLib -arg1 -arg2".execute()
def response = "Found text ${process.text}"
Your response var should now have value
Found Text This is my nice output
You can now use this to do what ever in a grails controller, like send it back to HTML..

how to convert an executable java jar file to an window service [duplicate]

This question already has answers here:
How to create a windows service from java app
(20 answers)
Closed 8 years ago.
I have created a jar file in java , the problem is when ever the system gets restart i need to manually run the jar file so i have decided to convert my jar file to a windows service . if anyone knows please help me out
The Java Service Wrapper makes it possible to install a Java Application as a Windows Service. Likewise, the scripts shipped with the Wrapper also make it very easy to install a Java Application as a Daemon process on UNIX systems.
The Wrapper correctly handles "user's log outs" under Windows, service dependencies, and the ability to run services which interact with the desktop.
Take a look at this
Java Service Wrapper

How to call a java function from a Php file? [duplicate]

This question already has answers here:
Run Java class file from PHP script on a website
(5 answers)
Closed 9 years ago.
I created a JAR file and i need to call its methods from a Php file. I tried doing it with Php-java bridge but, it works only with sun java 6 which is an abandoned version. Also, i feel that using php-java bridge is not the best way of achieving what i want as it was updated ages ago. Are there any other methods which i can follow to call my java functions from a php file?
Execute your java programm from PHP with shell_exec(comand to start your java programm), it will return you the output from your java programm as string. http://www.php.net/manual/en/function.shell-exec.php
See Run Java class file from PHP script on a website.
In a nutshell: Use PHP's exec() function. It needs to be done very carefully, as described in the referenced issue, but if you do it right, (I've found) it can be a cleaner solution than the bridge method.

deserialize file created with mfc CArchive in java

i have a windows app based on mfc that saves its doc using the CArchive (MFC) serialization class
i would like to load these files into my new andriod app but need some java code to understand the serialized data file format. once i pull it apart i can handle the data ok but don't really want to dissect CArchive created files myself. can anyone help, maybe a library out there somewhere?
See previous answers to this question (with respect to Ruby instead of Java) - Parsing CArchive (MFC classes) files in Ruby
Unfortunately, I think that you're going to have dissect it yourself.

Posting Processing code onto a website?

I have exported some Processing code (outputs sensor data to a textbox) to an
applet that includes the .jar and .html files. I have tried to insert this html on a
simple website that I created and the java applet doesn't work. Do I have to somehow
modify the html? I know that the .jar files are already in the same directory and
are referenced appropriately in the exported html code. Is there a better approach
to posting to a website? Thank you
I don't think that it is possible, due to security restrictions on applet communication.
More than likely you will have to write a small client/server program using sockets.
The idea would be to transmit the the output from your locally running client application to your applet(server) which would receive and display the data.
You could use any language with socket support obviously(Flash, PHP, etc.), but I assume you will want to stick with Java.

Categories

Resources