Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have heard sometimes that the front end of a program was written in language A and the back end in language B. Can i do it for desktop programs I make too? Like do the graphics with Java and the back end with C or C++. How do i do it?
PS. Sorry if its a newbie question because I am one.
edit 1
Because i am told that my question is too broad, here is what I exactly want. How can I link mt action listener in java with a C program? For example, if i have a button "next hundred primes" i want the button to be made in Java and primes calculated using C.
This can be done in one Java process with JNI, for example. Java effectively calls C++ as a library.
This can also be done multi-process by having Java process create a C++ process then capture its output as, for example, C++ process exit code, standard output or created file.
A third way to do this would be to have a long-running C++ process listen on a TCP socket then have the Java program communicate with its C++ back-end over the network, either on the same machine or across an intranet.
Other methods also surely exist. These are just a few I know off the top of my head. :)
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a working java app and now I would like to extend it to be controlled over ssh. Let's say I have a swing button that increases a counter. I would like to be able to ssh in that computer and say something $: myapp increase and have the button's action listener executed.
Maybe I'm using the wrong keywords but I could not find a solution. The 'kinda' solution I could think of is using signals but I'm not even sure if they can be used as I am used to from C and if that can be done without knowing the actual process ID.
Any material that can get me started would be welcome.
signals are hard to read from java, because there is a lot of difference between OSes on how to do those (some don't even have the concept), and java is designed to expose anything that can be generalized across all OSes java runs on, and to not expose anything that might not be there.
The usual way to do it, is via TCP/IP (so, java.net.Socket), or HTTP (so, jetty or some such).
Note that webapps can trivially be accessed remotely and can be scripted fairly easily. You could also consider building a command line / terminal based app, for example with lanterna which you can shove into a terminal session keeper / eternal SSH kinda deal.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to make a desktop GUI that interacts with the user's files (with permission of course). My code to download files and put it in the user's choice of directory is all written in python. There is much more to this code, but everything is written in python.
I want the GUI part to be a desktop app, so the client can easily interact and function the program.
I want to make this GUI in java and have it interact with the python code once someone presses a button.
What are the best approaches to make this happen?
I would do it like this:
Process p = Runtime.getRuntime().exec("python app.py");
You can also pass arguments into the python program as command line arguments, like this:
Process p = Runtime.getRuntime().exec("python app.py arg1 arg2");
You might be interested in jython
http://www.jython.org
Also, you might think about running Python using JNI - this way, you will be able to keep the state of Python process while still being inside Java:
https://github.com/mkopsnc/keplerhacks/tree/master/python
Everything heavily depends on what you really want to achieve.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have written a fully functional chat program in C. The server starts up and allows multiple clients to connect and talk to each other, all via command line. However I would like to try adding a GUI to this program, but all of the C/C++ GUI packages seem to have a steep learning curve just to get started. Is there any way to write a GUI using Swing and connect it to the C code underneath?
For example, I would like to type some text into a box, click "send" and have it call the C function which deals with sending text. Is this possible? And if so, is it very difficult?
I can provide code if needed. I am also open to suggestions on which C++ GUI package might be most appropriate for this kind of program.
Yes, its possible. You would have to use JNI. You should really consider the learning curve of doing JNI vs learning whatever GUI framework you want to use you C/C++.
As someone who has done this on multiple professional projects though, I really would warn against it. It can produce very hard to find bugs.
Tcl/Tk Used to be the scripting language of choice if you wanted to provide a bunch of C/C++ methods with a (not too complicated) GUI. Python also provides GUI element via PyQT and PyKDE. I think it's much easier to use a scripting language like this to bind to C then trying to do Swing<=>C/C++ bridging.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have written an RTMPS client a while back and needed it for my Django application but since Java and Python don't play well without using system calls (I don't want to use Jython) I wanted to rewrite the application in Python.
Would it work if I ported it as if to Python from Java? Of course we have to take into account the obvious things like multiple constructors have to be done differently in Python. Are there any other things that would not make it work in Python?
I am doing this because Java is so memory heavy and hoping that moving in into Python would reduce memory footprint and thus allow my web app to use it.
I would suggest rewriting it completely but there are a lot of differences to take into account. Here's a starter for recognizing some of the common differences/mistakes: http://dirtsimple.org/2004/12/python-is-not-java.html
Also if you are too lazy to rewrite the code (like me) there is an other option: java2python
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Is it possible to have event driven programming moving objects or characters in a cmd screen. And how?
For example a chess board when you do a move then we have to print for each move. We want to play it only one chess board.
Thanks..:)
It's very hard to make out what you're asking, but I think I hear two different questions:
Is it possible to do event-driven programming in assembly language?
Yes, it is. In fact, quite a lot of assembly-language programming is event-driven (handling interrupts and such).
Is it possible to write to specific parts of the console display rather than just outputting a stream of characters that scrolls?
Yes, on nearly all consoles. How you do so varies a bit by console. You could look into ANSI escape codes or similar, which work on a wide variety of console displays.