Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Common Enviroment for Windows and Mac

Posted on 2007-11-29
3
Medium Priority
?
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

718 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