Question

So I'm thinking about making a GUI. My friend told me he knew how to do it in C#, so I went that method in setting the GUI up. Is there anyway to get a C# made GUI usable in java?

Was it helpful?

Solution

I think you should learn how to make a GUI in Java if you are coding in Java. However if you want both of C# and Java to interoperate, then you need a new layer which acts like a bridge between a C# program runs on CLR and Java program runs on JVM. The following link has a good explanation about how to call Java routines directly from a C# program over runtime bridges:

http://www.devx.com/interop/Article/19945/1954

You need to bind something on GUI with an appropriate logic. Such as File>New menu selection might exist for creating a new file. Therefore this menu command needs to be bound to a logic. You can not run away without writing these logic, the event handlers or without defining some other functionalities inside of GUI classes. Strictly speaking, you always need to write a lot of code on presentation layer which consists of GUI classes. So that, your friend does also need to build up the presentation layer itself. Because a useless user interface is called a prototype not a program. And also do not forget about that runtime bridges significantly decrease the performance. Eventually, I suggest you to go and learn how to make GUI in Java.

OTHER TIPS

Yes you can. You absolutely should not. I once wrote a perl application that used a VB GUI that i made, they communicated via OLE.

This is probably the worst construct you could ever do so don't :)

Not practically. You can't just give the C# compiler a Java file, or vice versa.

If you're really determined though, you can use IKVM to expose Windows Forms to Java.

There's also J# but it's not being actively developed anymore.

No! It would not work. Java's GUI classes are different, so even if you renamed your .cs files to .java files and made slight modifications, the code would not work.

No. It won't work. You can't compile Java and C# into a single executable package.

No. The way Java and .NET interact with the GUI is totally different.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top