File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Platform interdependency and portability of Java programs

 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • 0
  • Mark post as helpful
  • send pies
  • 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.






 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic