> > 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
[quoted text clipped - 4 lines]
>
> 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 =

Signature
Steve W. Jackson
Montgomery, Alabama
Jean Pierre Daviau - 22 Dec 2006 20:12 GMT
>> The above command line only works if "myApplication.class" exists in
>> the directory where it's executed. That's true on Unix systems. And
[quoted text clipped - 8 lines]
> import java.io.*;
> import java.lang.Character;
// [grb] directly using sun.* packages is generally a Very Bad Idea(tm)!
> import sun.net.smtp.*;
> import java.util.Properties;
[quoted text clipped - 38 lines]
> 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
> 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.
> 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.
> SmtpClient smtp = new SmtpClient(".ca");
> smtp.from(sFROM);
[quoted text clipped - 24 lines]
> }
>}
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

Signature
---------------------------------------------------------------------
Greg R. Broderick gregb+usenet200612@blackholio.dyndns.org
A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------
Jean Pierre Daviau - 24 Dec 2006 17:51 GMT
// 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
Greg R. Broderick - 24 Dec 2006 20:32 GMT
"Jean Pierre Daviau" <Once@WasEno.ugh> wrote in news:V6zjh.10062$Ld4.127448
@wagner.videotron.net:
> Why does it work?
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

Signature
---------------------------------------------------------------------
Greg R. Broderick gregb+usenet200612@blackholio.dyndns.org
A. Top posters.
Q. What is the most annoying thing on Usenet?
---------------------------------------------------------------------