 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jean Pierre Daviau Guest
|
Posted: Fri Dec 22, 2006 4:49 pm Post subject: starting java |
|
|
Hi everybody,
There is no problem to start an application on windows (at least for me).
How do you start an appication on Unix and on Mac?
Is ther few lines of code I can get like it is on windows?
I have a friend who has a Mac. I sent her an application but her Mac does
not know how to start it . I found this
--------- start.sh -------
#!/bin/sh
java -cp . myApplication
--------- end start.sh -------
--
Thanks for your attention.
Jean Pierre Daviau
--
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
Processor Radeon7000 0x5159 agp |
|
| Back to top |
|
 |
Steve W. Jackson Guest
|
Posted: Fri Dec 22, 2006 9:35 pm Post subject: Re: starting java |
|
|
In article <_KOih.12812$pc5.216853 (AT) wagner (DOT) videotron.net>,
"Jean Pierre Daviau" <Once (AT) WasEno (DOT) ugh> wrote:
| Quote: | Hi everybody,
There is no problem to start an application on windows (at least for me).
How do you start an appication on Unix and on Mac?
Is ther few lines of code I can get like it is on windows?
I have a friend who has a Mac. I sent her an application but her Mac does
not know how to start it . I found this
--------- start.sh -------
#!/bin/sh
java -cp . myApplication
--------- end start.sh -------
|
You haven't provided anywhere near enough information to give a
definitive answer.
The above command line only works if "myApplication.class" exists in the
directory where it's executed. That's true on Unix systems. And the
modern Mac OS X system is based on BSD, so that it can work there as
well if your friend is willing to go into the Terminal program and type
the command at the right location. Most Mac users, however, aren't
familiar with this environment.
You need to provide more details. Better still, you should package up
your application, perhaps putting it into a jar file. I can assure you
that her Mac will know how to launch that if it's designed to be self
contained -- though it won't be all that pretty.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama |
|
| Back to top |
|
 |
Jean Pierre Daviau Guest
|
Posted: Sat Dec 23, 2006 12:48 am Post subject: Re: starting java |
|
|
| Quote: |
The above command line only works if "myApplication.class" exists in the
directory where it's executed. That's true on Unix systems. And the
modern Mac OS X system is based on BSD, so that it can work there as
well if your friend is willing to go into the Terminal program and type
the command at the right location. Most Mac users, however, aren't
familiar with this environment.
--
|
The jar is signed and clickable: at least on windows
-------------------------------------------------------
// File: SendMailDelayed.java - A tiny application
import java.io.*;
import java.lang.Character;
import sun.net.smtp.*;
import java.util.Properties;
public class PosteProps {
static String sTO = "daviaujp (AT) videotron (DOT) ca";
static String subj = "Java System Information";
static String message;
static File file;
public static void main (String[] args)throws Throwable {
getData();
System.out.println();
System.out.println("Sending EMail...");
if (SendMailDelayed(getData()))
System.out.println("EMail sent...");
else
System.out.println("Trouble sending your EMail...");
System.out.println();
}
static public String getData() throws IOException {
int i = 2000;
InputStream in2 = null;
char byteArray[] = new char[i];
StringBuffer strbuf = new StringBuffer();
Properties sysprops = System.getProperties();
strbuf.append(sysprops);
for (int j = 0;j < strbuf.length() ;j++ ) {
if (strbuf.charAt(j) == ',') {
j++;
strbuf.insert(j, "<br>");
}
}
String liste = strbuf.toString();
System.out.println (liste);
return liste;
}
static boolean SendMailDelayed (String texte) {
boolean bSuccess = true;
try {
String sFROM = "videotron.ca";
System.out.println (getData());
System.out.println("Beginning to send...");
SmtpClient smtp = new SmtpClient(".ca");
smtp.from(sFROM);
smtp.to(sTO);
PrintStream msg = smtp.startMessage();
msg.print("From: Jean Pierre Daviau\n");
msg.print("Subject: " + subj + "\n");
//msg.print("To: You\n");
msg.println("Content-Type: text/html");
msg.println("");
msg.println("");
msg.println(texte);
msg.println("");
smtp.closeServer();
System.out.println("Success: EMmail sent to: " + sTO);
} catch (java.net.UnknownHostException e) {
System.out.println(e);
System.out.println(" probably caused by bad host name, not connected
to the Internet,...");
bSuccess = false;
} catch (IOException e) {
System.out.println(e);
bSuccess = false;
}
return bSuccess;
}
} |
|
| Back to top |
|
 |
Steve W. Jackson Guest
|
Posted: Sat Dec 23, 2006 1:28 am Post subject: Re: starting java |
|
|
In article <NLVih.14650$pc5.282059 (AT) wagner (DOT) videotron.net>,
"Jean Pierre Daviau" <Once (AT) WasEno (DOT) ugh> wrote:
| Quote: |
The above command line only works if "myApplication.class" exists in the
directory where it's executed. That's true on Unix systems. And the
modern Mac OS X system is based on BSD, so that it can work there as
well if your friend is willing to go into the Terminal program and type
the command at the right location. Most Mac users, however, aren't
familiar with this environment.
--
The jar is signed and clickable: at least on windows
|
[ code snipped ]
What's in the code isn't relevant to the question you raised.
Your original question asked whether "java -cp . myApplication" would
work. It won't unless myApplication.class is present in the directory
where this command is issued.
If the application in question is inside a jar file (signed or not) with
a proper manifest that identifies its main class, then double clicking
works on Windows and in Mac OS X. But because of the difference in the
Mac's interface, it won't look too pretty.
If your Mac-using friend is comfortable enough to use a command line,
she could instead use "java -jar JarFileName.jar" if it's got a proper
manifest. If not, then the name of any class inside with a proper main
method can be used with "java -cp JarName.jar ClassName".
What you might notice is that what I just described is *precisely* the
same as it works on Windows systems.
When you install Java on Windows, the installer usually gives you a file
association for jar files that causes "javaw -jar filename" to get
invoked so that double-clicking works -- except it'll fail if there's
not a proper manifest. The very same is true in Mac OS X.
Other Unix systems (including Linux) may or may not have a graphical
mechanism like the double-click available, depending on configuration.
The command line technique should work equally for all.
= Steve =
--
Steve W. Jackson
Montgomery, Alabama |
|
| Back to top |
|
 |
Jean Pierre Daviau Guest
|
Posted: Sat Dec 23, 2006 2:12 am Post subject: Re: starting java |
|
|
| Thanks |
|
| Back to top |
|
 |
Greg R. Broderick Guest
|
Posted: Sat Dec 23, 2006 11:21 pm Post subject: Re: starting java |
|
|
"Jean Pierre Daviau" <Once (AT) WasEno (DOT) ugh> wrote in
news:NLVih.14650$pc5.282059 (AT) wagner (DOT) videotron.net:
| Quote: |
The above command line only works if "myApplication.class" exists in
the directory where it's executed. That's true on Unix systems. And
the modern Mac OS X system is based on BSD, so that it can work there
as well if your friend is willing to go into the Terminal program and
type the command at the right location. Most Mac users, however,
aren't familiar with this environment.
--
The jar is signed and clickable: at least on windows
-------------------------------------------------------
// File: SendMailDelayed.java - A tiny application
import java.io.*;
import java.lang.Character;
|
// [grb] directly using sun.* packages is generally a Very Bad Idea(tm)!
| Quote: | import sun.net.smtp.*;
import java.util.Properties;
public class PosteProps {
static String sTO = "daviaujp (AT) videotron (DOT) ca";
static String subj = "Java System Information";
static String message;
static File file;
public static void main (String[] args)throws Throwable {
getData();
System.out.println();
System.out.println("Sending EMail...");
if (SendMailDelayed(getData()))
System.out.println("EMail sent...");
else
System.out.println("Trouble sending your EMail...");
System.out.println();
}
static public String getData() throws IOException {
int i = 2000;
InputStream in2 = null;
char byteArray[] = new char[i];
StringBuffer strbuf = new StringBuffer();
Properties sysprops = System.getProperties();
strbuf.append(sysprops);
for (int j = 0;j < strbuf.length() ;j++ ) {
if (strbuf.charAt(j) == ',') {
j++;
strbuf.insert(j, "<br>");
}
}
String liste = strbuf.toString();
System.out.println (liste);
return liste;
}
static boolean SendMailDelayed (String texte) {
boolean bSuccess = true;
try {
|
// [grb] BAD, WRONG, etc.: this is not a valid email address, as required by
RFC 2821, section 4.1.1.2
| Quote: | String sFROM = "videotron.ca";
|
// [grb] you're calling getData() a second time here, why not just println
(texte), which contains the value passed into the method, from the prior
invocation of the getData() method.
| Quote: | System.out.println (getData());
System.out.println("Beginning to send...");
|
// [grb] if the parameter ".ca" is intended to be the hostname used in the
HELO/EHLO SMTP greeting, then it is not valid, insofar as it is not a valid
FQDN. C.f. RFC2821, section 4.1.1.1
// [grb] ??? where / how to you specify the hostname / IP address of the SMTP
server to which your SmtpClient is supposed to connect? I don't see this
anywhere in your code.
| Quote: | SmtpClient smtp = new SmtpClient(".ca");
smtp.from(sFROM);
smtp.to(sTO);
PrintStream msg = smtp.startMessage();
msg.print("From: Jean Pierre Daviau\n");
msg.print("Subject: " + subj + "\n");
//msg.print("To: You\n");
msg.println("Content-Type: text/html");
msg.println("");
msg.println("");
msg.println(texte);
msg.println("");
smtp.closeServer();
System.out.println("Success: EMmail sent to: " + sTO);
} catch (java.net.UnknownHostException e) {
System.out.println(e);
System.out.println(" probably caused by bad host name, not
connected
to the Internet,...");
bSuccess = false;
} catch (IOException e) {
System.out.println(e);
bSuccess = false;
}
return bSuccess;
}
}
|
Somewhat off-topic, the messages that your code is sending are not compliant
with RFC 2822, because they do not contain the required "Date:" header.
Your code is also not compliant with RFC 2821 (SMTP) as the "email address"
that you have specified
For MIME, you also need more than just the "Content-Type:" header. You need
at least:
MIME-Version: 1.0
and
Content-transfer-encoding:
Furthermore, if your message contains eight bit data (very likely, if you're
using accented characters), you will need to encode it to be seven-bit,
because SMTP only guarantees seven-bit data transmission. The two popular
methods of encoding are QP (quoted-printable) and base64.
I'd personally recommend that you use something such as JavaMail instead of
attempting to do this all yourself.
Cheers!
GRB
--
---------------------------------------------------------------------
Greg R. Broderick gregb+usenet200612 (AT) blackholio (DOT) dyndns.org
A. Top posters.
Q. What is the most annoying thing on Usenet?
--------------------------------------------------------------------- |
|
| Back to top |
|
 |
Jean Pierre Daviau Guest
|
Posted: Sun Dec 24, 2006 11:51 pm Post subject: Re: starting java |
|
|
// File: SendMailDelayed.java - A tiny application that sends an EMail
message using SMTP
// A superior way to send (and receive) EMail is to use Sun's JavaMail
support
// But, that is far more complex... and requires downloading additional
libraries
// So, for now, this tiny example should suffice
/* Furthermore, if your message contains eight bit data (very likely, if
you're
using accented characters), you will need to encode it to be seven-bit,
because SMTP only guarantees seven-bit data transmission. The two popular
methods of encoding are QP (quoted-printable) and base64. */
/*
import java.io.*;
import java.lang.Character;
import sun.net.smtp.*; // Note that sun.net.* packages are UNSUPPORTED
import java.util.Properties;
import java.util.Date;
public class PosteProps {
static String sTO = ".ca";
static String subj = "Java System Information";
static String message;
static File file;
public static void main (String[] args)throws Throwable {
System.out.println();
System.out.println("Sending EMail...");
if (SendMailDelayed(getData()))
System.out.println("EMail sent...");
else
System.out.println("Trouble sending your EMail...");
System.out.println();
}
static public String getData() throws IOException {
int i = 2000;
InputStream in2 = null;
char byteArray[] = new char[i];
StringBuffer strbuf = new StringBuffer();
/*
final String separator = System.getProperty(line.separator);
final int separatorLength = separator.length();
for (int j=0;j<strbuf.length() ;j++ )
{
if(strbuf.charAt(j) == ','){
strbuf.insert(j, separator);
j += separatorLength;
}
}
*/
Properties sysprops = System.getProperties();
strbuf.append(sysprops);
for (int j = 0;j < strbuf.length() ;j++ ) {
if (strbuf.charAt(j) == ',') {
j++;
strbuf.insert(j, "<br>");
}
}
String liste = strbuf.toString();
System.out.println (liste);
return liste;
}
static boolean SendMailDelayed (String texte) {
boolean bSuccess = true;
// [grb] directly using sun.* packages is generally a Very Bad Idea(tm)!
try {
String sFROM = "vidn.ca";
System.out.println("Beginning to send...");
SmtpClient smtp = new SmtpClient(".ca");
smtp.from(sFROM);
smtp.to(sTO);
PrintStream msg = smtp.startMessage();
//msg.setText(msg, "fr-ascii");//us-ascii deleteMe
/* msg.println(new Date().toString());*/
msg.println("MIME-Version: 1.0");
msg.println("Content-transfer-encoding: CHARSET=ISO-8859-1");
msg.println("Content-Type: text/html");
msg.print("From: Jean Pierre Daviau\n");
msg.print("Subject: " + subj + "\n");
msg.print("To: You\n");
msg.println("éàô££££");
msg.println("");
msg.println(texte);
msg.println("");
smtp.closeServer();
System.out.println("Success: EMmail sent to: " + sTO);
} catch (java.net.UnknownHostException e) {
System.out.println(e);
System.out.println(" probably caused by bad host name, not connected
to the Internet,...");
bSuccess = false;
} catch (IOException e) {
System.out.println(e);
bSuccess = false;
}
return bSuccess;
}
}
=============
Why does it work?
I took off the personnal informatons
Received: from jean-pier([66.131])
by VL-MH-MR002.ip.videotron.ca
(Sun Java System Messaging Server 6.2-2.05 (built Apr 28 2005))
with SMTP id <0JAS0089Avtron.ca> for
.ca; Sun, 24 Dec 2006 12:45:17 -0500 (EST)
Date: Sun, 24 Dec 2006 12:45:17 -0500 (EST)
Date-warning: Date header was inserted by VL-MH-MR002.ip.videotron.ca
From: Jean Pierre Daviau
Subject: Java System Information
To: .ca
Message-id: <0JAS0089CHMH-.ca>
MIME-version: 1.0
Content-type: text/html
*/
___
éàô££££ {user.language=fr,
java.home="C:\Program Files\Java\jre1.5.0",
etc.
---
JPD |
|
| Back to top |
|
 |
Greg R. Broderick Guest
|
Posted: Mon Dec 25, 2006 2:32 am Post subject: Re: starting java |
|
|
"Jean Pierre Daviau" <Once (AT) WasEno (DOT) ugh> wrote in news:V6zjh.10062$Ld4.127448
@wagner.videotron.net:
Because the particular mail server that you're using is obeying one of the
prime principles of the Internet, "Be liberal in what you accept and
conservative in what you produce.", and is accepting your broken email,
which you should not be producing.
Not all mail systems will necessarily be so accepting of broken emails such
as yours, therefore it is highly recommended that you follow the published
Internet Standards documents to the absolute best of your ability to do so.
This will insure maximum interoperability.
Cheers
GRB
--
---------------------------------------------------------------------
Greg R. Broderick gregb+usenet200612 (AT) blackholio (DOT) dyndns.org
A. Top posters.
Q. What is the most annoying thing on Usenet?
--------------------------------------------------------------------- |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|