Solved

Common Enviroment for Windows and Mac

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

762 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

20 Experts available now in Live!

Get 1:1 Help Now