Add Java GUI to C client [closed] - java

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.

Related

How to display values form a python program output in a Swing GUI developed in Java [closed]

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 am trying to create a graphical user interface (GUI) using Swing in Java.
The part I am kind of stuck is, I am planning to display some values from my Python program to the interface I am developing in Swing. I have looked up in forums and came across the Jython thing, but not quite sure on how to proceed with this, anyone information in this issue would be helpful to me.
Some extra information, if it may help, I have a set of sensors reading some values using a Raspberry Pi, and the sensors are operated using a Python script running in RPi. Now my goal is to develop a GUI using Java so that I can display those values from the Python script to the swing interface.
Thanks in advance.
I think your easiest path forward would be to store the values that are collected by the Raspberry Pi in an intermediary storage. This can be as simple as a text file, or if you want something more verbose, you can store it in a RDBMS or NoSQL DB. Then it becomes easier for the java application to look up the values without having to interface with Python.
If you want to directly interface with Python, you could look into GraalVM which has limited ability to directly execute Python code.

Good practices for Data Scientists that work in R and engineers who work in Java and C++ collaborating [closed]

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
My company has a production application being built in Java and C++. We have recently added Data Scientists who are skilled at and using R. I am wondering what best practices people have for making sure that work done in R is best leveraged. For instance is our best option to call R code from Java or C++? I have located http://www.renjin.org/about.html.
Or is there a good way to convert code from R to Java or C++?
I am not a big fan of Renjin as its Java-based interpreter will only cover a subset of CRAN, and at that the subset that does not involve calls to C++.
I am a bigger fan of either
separation of concern:
use something like Rserve for headless connection from anything (including Java), or
use something like OpenCPU to turn everything into web-based access
for heavier-duty work, interface C++ directly via Rcpp which well over 400 CRAN packages do.

Make my game moddable [closed]

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 want to make my Java game moddable. I was thinking about Lua but I don't like this idea too much. Basically I just want to make API for my game that'll contains some methods that will be available for people making mod. After I make the mod I want to somehow compile it into a jar file. The most tricky part is to load the file (mod) as a mod. I've never done anything like that, but I've created some mods for game Minecraft using Minecraft Forge API so I know that it's possible.
I want to make my Java game moddable.
IMO, the best way to do this is to make the complete source-code of your program available freely to anyone who wants it.
But assuming that you mean "mods" to your game that don't involve people hacking on the core code, there are standard ways of implementing "plugin" functionality in Java. Basically, you structure your application so that the areas where you want the behaviour to be "mod-able" have:
a well designed interface that "mod" coders can implement,
a plugin loader that finds and loads custom code (mods) from somewhere, and
some kind of registry mechanism that allows your application to find the code.
In addition, making the code open source makes it a lot easier for mod coders to code and debug their mods. If they can see the core code, they can figure out how they need to write their code to interact with it.

Making MATLAB Code Platform Independent [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a MATLAB code (including Simulink models) which I would like to make platform-independent, i.e., allowing them to run on web browsers and smartphone apps. Would coding it in Java be the best solution? And are there programs which can convert MATLAB code and Simulink models into another programming language easily so that I won't have to re-code everything out again? Thanks for your suggestions!
Short answer: You'll have to recode
Would coding it in Java be the best solution?
Probably not. I've found that java is hardly ever the best solution. It may be the easiest, but I doubt it's the best. But for web-browsers, AFAIK, you must render some part down to javascript (even if it's just a shim to fetch data running on a server), flash, silverlight*, or java*. For iphone, you need to do it in C, Objective-C, or C++. I think Android uses some kind of java-like/based language, but I don't know. I doubt Win Mobile 8 even has a JVM, but don't really know there.
* Few people like to leave these plugins open. Too easy to exploit and few sites use them.
And are there programs which can convert MATLAB code and Simulink models into another programming language easily so that I won't have to re-code everything out again?
Mathworks makes an m-code compiler, but you still need a lot of their libraries. It compiles for x86 under Windows and Linux. I think it supports a few other OS's, but all x86 unless they changed it around again. I guess you could try to get MCR working on a phone, but not in a web browser. Realtime Workshop renders simulink models to C, but not if they contain matlab function blocks (or some other blocks, I forget the full list). I hope you have a crap ton of cash, 'cause both those are expensive toolsets.

Extend already existing open source php tool in java [closed]

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
Please tell me, is it possible to extend any PHP based tool in Java programing language.
I am trying some open sourcve tools and found one satisfactory to most of my requirment. But my problem is that, the tool i found is developed in PHP language but i know only java language and there are some business requirment as well. I need to add some more features in this tool. What is the best possioble way to achieve this extension.
Please guide me friends.
Thanks a lot.
You can't wrap or extend PHP code from Java the way you would a Java library, but you might be able to call PHP code on your server and work with the results from your own Java application. See How can I execute a PHP script from Java?
Barring than that, I agree with the comment above. It might be easier to either learn PHP or rewrite the parts of the code that you need in Java.
After seeing in your comments what PHP tool you're talking about, rewriting in Java doesn't seem like much of an option. If you're starting a site from scratch (meaning you don't already have a Java application that you want to add this to) then PHP is not that hard to learn. Other than that, you could look for Java projects that do the same thing as the PHP tool you're looking at now.
Well, it would be useful if you'd tell us what exactly your PHP tool/framework does, maybe even give us a link to it's site, then I'm sure you'll get tons of recommandations for corresponding Java tool/framework that does the same thing. I don't think you need to remake a PHP tool in Java by hand, really I can't think of PHP libraries that don't also exist for Java as well...

Categories