Can I make a GUI using NetBeans but implement functionality using C? - c

I want to use NetBeans to build the GUI for my project, but implement the functionality using C code. Is there any way I can make the C code run when a button in the GUI is clicked?

I believe you can use standard JNI with netbeans.
Here's a link for version 6.0, (http://www.netbeans.org/kb/60/cnd/beginning-jni-linux.html) which I hope still applies for 6.5.
Once you set up a basic JNI C-library with the appropriate headers, it's pretty easy to use from the java side. And once you have that much done, it's even possible to throw Java Exceptions from the C code (http://www.codeproject.com/KB/debug/jni_ex.aspx)
But you should take note that if you're sending a lot of data back and forth, the overhead of the JNI data passing could be greater than the gain of using C for your speed-critical sections.
Cheers

You could use Java Native Access (JNA), a new technology. With JNA, Java applications can dynamically access native libraries from Java without JNI. JNA allows you to call directly into native functions using natural Java method invocation.
The project home page is here:
https://jna.dev.java.net/
Wikimedia article:
http://en.wikipedia.org/wiki/Java_Native_Access

Related

How can I incorporate a C project in Xamarin Forms?

I have a project, written in C which I want to use in Xamarin Forms. What is the best way to use this code? Generate libraries for each platform?
What I'd prefer is to have one wrapper that I can use in shared code that doesn't have to be implemented for each platform.
Unfortunately, the way binding works is different for Android and iOS, so you would need to generate libraries for each platform.
You can read more about how that is done here for iOS and here for Android. For iOS, you can consider using Objective Sharpie which will do the most of the work for you.
Afterwards, you can simply use DependecyService to access the native platform features.

Can i create apple or android application using c?

I was wondering if i can create an application using C because android applications nowadays are programed using java and i don't have a lot of knowledge in Java programing
You can use something called the NDK to create statically linked libraries that Android can call. Remember these are linked libraries (.so files) and so they do not have a Main in the traditional sense. To find more information on that follow this link. http://developer.android.com/tools/sdk/ndk/index.html
It's important to note that you will still need to write some Java code but it allows you to do a lot of the non GUI work via C code.
On the flip side IOS programs are written in Objective-C which sounds similar to C but from what I've been told it's very far apart.

Can native C programs be used in LibGDX?

I have a program in C which i would like to call and use it in LibGDX so that i can use it both for android and desktop. So can you suggest me methods to call a C file into LibGDX?
To be clear, I believe you have an app written in Java that uses Libgdx currently, and you would like to extend that app by including a C library and making calls out to the C library from the Java application.
Libgdx does not provide any special support for third-party libraries, native or Java. You will have to use the backend platform's APIs to call out to native code (JNI, NDK, etc).
You should be able to add your library to the Android and Desktop backend projects, and access it via a Platform Interface. It is probably not possible to use the GWT-backend (unless you have a C to Javascript compiler). For iOS you would need to build your library for iOS, and then figure out how to link it into the Xamarin (or robovm) build process for your app. While I'm going to assume this is possible, I suspect neither is easy to accomplish.

monodroid library in winforms

I am new to MonoDroid so maybe there is an easy answer, but so far searching hasn't turned it up... Since deploying to the Android emulator takes _for_ever_ on my PC, I would like to put most of my logic into a separate library and test it from a separate winforms application. Later, I can build a regular MonoAndroid application that provides the UI and just calls the library. However, when I try to link to the MonoAndroid class library I get this message:
Warning 1 The project 'MonoAndroidClassLibrary1' cannot be referenced. The referenced project is targeted to a different framework family (MonoAndroid)
Is there another way to achieve this objective? Yes, I could simply create a separate standard windows library and copy/paste the code between the two, but there must be a better way
You can use this extension http://msdn.microsoft.com/en-us/library/ff921108%28v=pandp.20%29.aspx
You would need to create a regular .Net 2.0/3.5/4.0/etc class library and copy (or link) your source code files into it. Use this assembly for testing in winforms, and the Android class library copy for Android.
Of course, this will only allow you to write code that doesn't reference anything in the Mono.Android.dll assembly.

How do I get a C program to work as a Windows Application Form?

Hi I am a beginner in C programming and I have made a C program that automatically logins into a website using socket programming, particularly made for UNIX systems. I am now interested in bringing this program into "life" in windows application form, so that it would be much easier to use. But I am clueless on where to start because I have never programmed in Windows before. A simple guide to what steps I should take would be very much appreciated. Thank You.
Get yourself a Windows installation and install an express version of the C++ IDE. In there you can create Win32 API applications from which you could start to build your app. You will need to use the Win32 API to build your form. This API is fairly well documented on the internet. Here is a website with some tutorials on it.
Hope this helps.
You could use a library for that. For example i like Qt but it tends to be large but it is multiplatform. You could also use Win32++ for that. But it requires some reading since it is very close to the windows api (WinAPI).
Just for completeness there is also ATL, WTL, MFC, GTK (multiplatform), wxWidgets and some others i don't recall.

Resources