I wanted to receive mail with Raspberry Pi, so I decided to use javaMail. Since javaEE is not included in Raspberry Pi by default, I decided to include javaMail alone.
This time, I will make a note of this because I focused on the classPath that I had not been familiar with until now.
It seems that javaMail and JAF are used to use javaMail, so download both from the following URL. -JavaMail ・ JAF
If you unzip the two downloaded files, the following directory will appear.
To use javaMail, set two jar files, mail.jaf and activation.jar, in your CLASSPATH.
There are two main ways to set the UNIX CLASSPATH, and the method differs depending on the shell. Reference: Classpath
//shell(csh)in the case of
setenv CLASSPATH classpath 1: classpath 2
//shell(bash)in the case of
CLASSPATH=Classpath 1: Classpath 2; export CLASSPATH
**Checking the shell**
echo $SHELL
You can find out what the shell of your OS is by clicking "Check Shell". Raspberry is bash. In my case it looks like this. Also, separated by: (colon). (Dot) represents the current directory.
This completes the CLASSPATH setting.
Compile the following silly program to make sure the CLASSPATH is set.
Sample.java
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Sample{
public static void main(String args[]){
System.out.println("OK");
}
}
I think it's okay if you can compile with this without any problems.
Until now, I wasn't sure about CLASSPATH, but now I can use it with this "this". The details remain ambiguous, but let's do this this time! !!
It took a long time to set up, and I was tired and the notes became cluttered. From the next time, I want to finish the work more efficiently.
I don't know anything about this field, so if you make a mistake, please point it out in the comments. Also, please comment if you would like to share some tips.
Recommended Posts