2

I have a well developed Windows application in C# and .Net, which works well in UI (Forms) mode and in command line mode as well.

However now, it is required to be able to be used on other platforms like Mac and Linux.

Would it be possible to use the same without recoding or redeveloping it in Java?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Indigo
  • 2,887
  • 11
  • 52
  • 83

3 Answers3

5

Well for cross-platform .NET you can look at the Mono project.

Mono is a software platform designed to allow developers to easily create cross platform applications. Sponsored by Xamarin, Mono is an open source implementation of Microsoft's .NET Framework based on the ECMA standards for C# and the Common Language Runtime. A growing family of solutions and an active and enthusiastic contributing community is helping position Mono to become the leading choice for development of Linux applications.

Dimitar Dimitrov
  • 14,868
  • 8
  • 51
  • 79
  • Well, I just checked it with mono and it shows there are a lot of things in my code which are not compatible and needs to be changed. Doesn't seem to be much more robust and practical job. – Indigo Aug 20 '13 at 10:13
  • 1
    @ChP, mate when you do cross-platform you're bound to do changes in your code, I'm absolutely certain however that this would require less "changes" than if you go in the Java direction. – Dimitar Dimitrov Aug 20 '13 at 10:17
  • I agree, in my case, I used Windows API, which is definitely need to be changed. I guess, I just have to spend some time optimizing C# code to remove all OS dependent code and then try using with Mono. Later if possible can use it in the background with JavaFX based GUI as mentioned in one of the answer here by Andrew. – Indigo Aug 20 '13 at 14:30
4

Would it be possible to use the same without recoding or redeveloping it in Java?

Yes. Swing and JavaFX are the GUI tool-kits to look at for desktop apps. Both are supplied by Sun/Oracle (with the 1.2/1.7 Java versions respectively), and open source. Of course, Java supports layout localization (e.g. a layout constraint of LINE_START will position a component on the left if user has a left-to-right language, and on the right if their local language is written right-to-left) and language localization (IL8N).

  • Java FX is Oracle's 'next generation' GUI toolkit. I have not had experience with it yet, but know it is cross-platform.
  • Swing is a comprehensive, mature, robust GUI toolkit. Swing supports Layout Managers & Look-&-Feel, which combined allow us to show a GUI in the 'native' look and feel, and also size and position the components logically for that look. See the Nested Layout Example for code & screenshots (2 below) that show the end result.

Windows Look & Feel

OS X 'Aqua' Look & Feel

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • Thanks, it is helpful, although, at the end I would end up coding my application in JAVA itself instead of searching for shortcuts... – Indigo Aug 20 '13 at 10:18
  • *"..would end up coding my application in JAVA.."* Having corrected it in your question, I will now explicitly point out that it is **Java** not **JAVA**. *"..instead of searching for shortcuts."* What 'shortcuts'? Do you mean in the command line version written in .Net? I was proposing to do the **GUI in Java*** and have it use the existing (non-GUI) .Net code for the rest of it. As far as 'short cuts' in the GUI code, seems it will be a lot shorter to write in Java than Mono. E.G. a good question for the Monites is 'How many LOC does it need for the example GUI?' <150 in Java. – Andrew Thompson Aug 20 '13 at 10:27
  • Thanks Andrew for pointing out it is Java not JAVA. :-) With shortcuts, I meant, I was trying to find shortcuts to stay away from coding in Java. So shortcuts to somehow use C# .Net application on other platforms like to convert them in Java or using Mono. Indeed, I tried to use JavaFX Scene Builder along with NetBeans and seemed pretty much easier, although have to look at the details. And this is also a very good approach to use Java based GUI and use .Net based command line application in background. Certainly, will give it a try. – Indigo Aug 20 '13 at 14:24
2

Would it be possible to use the same without redeveloping it in Java?

yes,use Mono. you can look at the Mono project

you might face some issues while executing in Linux and Mac

  1. .resx file won't execute in mono .Either you have to develop mono specific UI using Monodevelop or select the .resx files build action property as none
  2. Use Path.Combine instead of hard coding the path
  3. Use Preprocessor directives such as #if ..#elif.. #endIf for platform specific code execution
Sumeshk
  • 1,980
  • 20
  • 33
  • *"you might face some issues while executing in Linux and Mac"* *"..mark answer as solution if it is..."* It hardly seems like one, given the 3 point list of caveats. – Andrew Thompson Aug 20 '13 at 10:14
  • Yes exactly, got a lot of issues while checking with mono and I believe it must be more easier to write it in JAVA than adjusting previous code to be compatible with hmono and encounter errors later. – Indigo Aug 20 '13 at 10:15
  • @Chp :That depend on the size of your application ,if it is large redeveloping might be costly. – Sumeshk Aug 20 '13 at 10:23
  • @Sumeshk: Yes, that's correct. Even if it is a medium level application, It is going to take a considerable time and resources. – Indigo Aug 20 '13 at 14:18
  • @chk: Executing the application in Mono Develop is interesting, because we can easily solve the above issues. But some windows platform specific features won't work in Linux and mac need to avoid that codes by adding preprocessor directives. – Sumeshk Aug 21 '13 at 04:27