Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Ramaswamy Narayanan

Greenhorn
+ Follow
since Jan 19, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ramaswamy Narayanan

please try with KeyListener
13 years ago
hi Ganesh

in your code, i have only changed the to,from,cc,bcc,subject.
but i got the following error message.

DEBUG: setDebug: JavaMail version 1.3.2
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.s
mtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "your SMTP server IP", port 25, isSSL fals
e
Unable to send your messagejavax.mail.MessagingException: Unknown SMTP host: you
r SMTP server IP;
nested exception is:
java.net.UnknownHostException: your SMTP server IP

What is the problem?
13 years ago
Actually my code is
import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

// Send a simple, single part, text/plain e-mail
public class TestEmail {

public static void main(String[] args) {

// SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
String to = "abcd@yahoo.co.in";
String from = "zyxw@yahoo.co.in";
// SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
String host = "mail.yahoo.com";

// Create properties, get Session
Properties props = new Properties();

// If using static Transport.send(),
// need to specify which host to send it to
props.put("mail.smtp.host", host);
// To see what is going on behind the scene
props.put("mail.debug", "true");
Session session = Session.getInstance(props);

try {
// Instantiatee a message
Message msg = new MimeMessage(session);

//Set message attributes
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject("Test E-Mail through Java");
msg.setSentDate(new Date());

// Set message content
msg.setText("This is a test of sending a " +
"plain text e-mail through Java.\n" +
"Here is line 2.");

//Send the message
Transport.send(msg);
}
catch (MessagingException mex) {
// Prints all nested (chained) exceptions as well
mex.printStackTrace();
}
}
}//End of class

here what is the isp's server(what is host name)?
13 years ago
i need extra information about the 'text2' variable.
is it a String variable contains integer data?
13 years ago
Hi Shailesh Munje

i am sorry to say that i am not able to solve your problem. but i need one help from you.
how to send email from java mail api.
please help me.
thank you
13 years ago
hai friends

i am doing a project. in that, i have to send email on clicking a button.
is it possible from java.

actually i got some help from a site.
it is we have to use javamail api.
but in that program i have to give a isp's mail server.
what it means?
if anybody knows, please help me.
thank you
13 years ago
to use the parseInt mehtod, you have to give the parameter which is a strnig but it has the integer value.

That is,
String str="100"
int i=Integer.parseInt(str);
13 years ago
In java, we can change any data type to string by adding with a string.
if i have the String
int i=0;
String str=""+i;

now the value of i is 10 and the value of str also i.
we can perform mathematical operation on i and not str eventhouth str is an integer.
so we have to convert the str to an integer format.
for that
int x=Integer.parseInt(str);
then the x contains integer variable.

The solution is
from the string having the integer value, we can get integer using the parseInt funtion.
13 years ago
Hello friends

i want to work java in linux.
i have checked the option for java while installing the linux.
how to set path?
how to compile and run? are the commands are same?
in which editor, i have to work (like command prompt in windows).

please help me.

thank you
13 years ago
hai friends
i am using jexcelapi for reading and writing spreadsheets from java.
i have a problem with it.
The problem is, i want change the default column width of a particular column.
There is a method to change the default column width of all the columns.
is it possible to change the width of a particular column?
if possible, pls reply immediately.
bye
narayanan
13 years ago
The FileOutputStream object has methods to write a character or byte array.
It has no method to write string.
Instead you can use DataOutputStream.
The DataOutputStream object has a method writeChars(string).
The sample code is

DataOutputStream out=new DataOutputStream(new FileOutputStream("ram.txt"));
out.writeChars("Jai Shri Ram");
out.writeChars("Jai Anchaneya");

pls try this.
13 years ago
To copy a file, we can simply use FileInputStream and FileOutputStream.
it will be used for all types of files.
the code is
try
{
FileInputStream fin=new FileInputStream(source file);
FileOutputStream fout=new FileOutputStream(destination file);
int i;
while((i=fin.read())!= -1)
fout.write(i);
}
catch(Exception e)
{}
13 years ago
hai friends
i am using jexcelapi for reading and writing spreadsheets from java.
i have a problem with it.
The problem is, i want change the default column width of a particular column.
There is a method to change the default column width of all the columns.
is it possible to change the width of a particular column?
if possible, pls reply immediately.
bye
narayanan
13 years ago
hello friends

i need to copy a word file(.doc file) from one folder to another.
is it possible? if yes, how?
please help me immediately.
thank you
by
narayanan
13 years ago
hello friends,

i need to access word file from java.
for that i need hwpf or hdf package.
how to download these packages.
please help me immediately.
thank you
bye
narayanan
13 years ago