Search code examples
c#javacross-language

Will a .cs file work in a .java software?


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?


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.