• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to create a WAR file on Windows for deployment on UNIX?  RSS feed

 
Dan Farrow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Java development. I am building a Java app on my Windows machine in NetBeans IDE and it creates WAR files when I build the project. I sent these WAR files to the client and they said I need to build the WAR files for the UNIX file system. How does one accomplish this on Windows?

Thanks,
Dan
 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The war files are not dependent on OS in anyway.

What is the problem that your client is facing when trying to deploy the war file on a unix system?
 
Tim Holloway
Saloon Keeper
Posts: 18789
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the beginning was the ZIP file (well, there were things before that, but you have to start somewhere).

And Sun added META-INF/MANIFEST.MF and called it a JAR file.

And Sun mandated a WEB-INF, with lib, classes and a web.xml file and it became a WAR file.

And it didn't give a flip about what the OS was.

However, I think that more likely, what the client meant was one of 2 things.

1. You transmitted the WAR in text mode (via FTP, for example). But, like ZIP files, WARs are binary, and when doing text-mode transmissions between Windows and Linux, the file will be altered to allow for Windows text line endings, thus damaging the WAR and making it unusable.

2. You coded Windows-specific stuff into the webapp itself. For example, there's no such thing as a "C:\Program Files" in any OS but Windows, and that includes Linux.

Java has a "normalized" file system convention, incidentally. That means that even under Windows, a file name can be coded using forward slashes instead of backslashes. I recommend that, because it reduces errors that arise when you forget to double up on backslashes in filename literal strings. I also recommend building directory paths using the "new File(directory, filename)" method. It eliminates the annoyances of having to build up paths using the OS-specific path separator.

In any event, you should NEVER hard-code the path separator. If you must use the separator string, get the OS-specific separator from the System properties.
 
Dan Farrow
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, thanks for the information. I do have a file path in my code, so I changed the code so that the separators come from the Java.lang.System "file.separator" property. I also re-uploaded my WAR file via binary mode FTP. Hopefully that will work.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!