Solved

Common Enviroment for Windows and Mac

Posted on 2007-11-29
3
180 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json example 39 132
Java Message handling in Service Layer 3 57
DO we need Java installed on a Windows PC and WHY ? 13 98
java stored proc example 9 22
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now