Solved

Common Enviroment for Windows and Mac

Posted on 2007-11-29
3
181 Views
Last Modified: 2010-03-30
In my program I am creating a zip file and FTP it to a server.  All that is working now, thanks to those who helped.  But my next problem is that my program is now running on a windows box so

   String target = "C:\\target.zip";

that works, but this program will also be running on Mac machines.  

Is there a standard ENV I can write and read the zip file from that will work on both platforms?
If so how would I go about setting it up?
0
Comment
Question by:Jaziar
  • 2
3 Comments
 
LVL 17

Expert Comment

by:contactkarthi
ID: 20374083
you can use a properties file

or you can specify the source at the startup and use it in the program like

java myprgram "c:\\target.zip"
or
java myprogram "/usr/folder/target.zip"

inside the program in the main method get the path and use it

public static void main(String args[])
{
String path=args[0];
}
0
 

Author Comment

by:Jaziar
ID: 20374194
I am a little confused

If I use

java myprgram "c:\\target.zip"
or
java myprogram "/usr/folder/target.zip"

would that cause the same problems I have now?  I need to be able to work on both platforms, whether it is mac or windows.  You're suggestion may be correct and I just don't understand it.  I am pretty new to java.
0
 
LVL 17

Accepted Solution

by:
contactkarthi earned 125 total points
ID: 20375094
if you are running from windows use java myprgram "c:\\target.zip"

from linux use ava myprogram "/usr/folder/target.zip"

or you can do this

String path = null;
if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") == -1) {
 path = "/usr/folder/target.zip";
}
else
{
 path="c:\\target.zip";
}
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java 8 lambda expresssions exception handling 3 91
how to add new optional parameter to JSP 1 42
Oracle SQL syntax check  without executing 6 55
spring jars download 1 27
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question