• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Platform interdependency and portability of Java programs

 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All,

My question is on platform interdependency and portability of Java programs.

I have written a simple application using Java Swing (say its is a small product) and tested completely. Now i have to install this application in new Linux and new Windows OS. What are all the steps that i need to do for the application to work in new machines?

My questions are:

1. Do i need to change code for Linux and Windows?
2. Do i need to install JVM / JDK / JRE in new machines? If then, Is the JVM / JDK / JRE is different for Linux and Windows?
3. Application has 60 Java files. How do i package the application?
4. I don't want to transfer the source code (.java files) to new machines. Even decompilation should not be allowed. How can i achieve that?

Thanks
Mathews.






 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mathews P Srampikal wrote:Dear All, . . .
1. Do i need to change code for Linux and Windows?

As long as you have avoided platform-sensitive code like \\ for path separator or \n for line end, no.


2. Do i need to install JVM / JDK / JRE in new machines? If then, Is the JVM / JDK / JRE is different for Linux and Windows?

Yes. Yes. You want a JRE.


3. Application has 60 Java files. How do i package the application?

Like this?


4. I don't want to transfer the source code (.java files) to new machines. Even decompilation should not be allowed. How can i achieve that?

By keeping the entire code on your machine and exporting the application as a web service. It is easy to deploy .class files only, but they can be decompiled.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. No, you don't need to change the code - you do not even have to recompile it. Java class files are portable across platforms. Ofcourse, as Campbell said, if you have used platform-specific constructs in your code, then you might get trouble on other platforms.

2. Yes, you need a JRE. The JVM / JRE /JDK is different for different operating systems, but that doesn't matter for your Java program.

4. There is no need to distribute source (.java) files. As said at point 1, your compiled code should just run on any platform for which there is a JRE. The only way to prevent people from decompiling the code is to not give them the code - instead of making it a stand-alone desktop program, make it a program on the web, with the code running on your server, instead of the client's computer. If you don't want that, you can use an obfuscator to make your code harder to decompile, but it won't be completely impossible to prevent it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic