Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:50:46+00:00 2026-06-01T05:50:46+00:00

I created a Java program which sends an email from my gmail account. I

  • 0

I created a Java program which sends an email from my gmail account. I programmed it in Eclipse and it works fine. But when I attempt to call it from PHP i get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Address
  at sendVerificationEmail.main(sendVerificationEmail.java:3)
Caused by: java.lang.ClassNotFoundException: javax.mail.Address
  at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

Here’s the command Eclipse uses:

/usr/lib/jvm/java-6-openjdk/bin/java -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:53094 -Dfile.encoding=UTF-8 -classpath /home/****/dir/to/program/java/bin:/home/****/dir/to/program/java/lib/javamail-1.4.4/mail.jar sendEmail

Here’s the command PHP uses:

exec("java -classpath /home/****/dir/to/program/java/bin:/home/****/dir/to/program/java/lib/javamail-1.4.4/mail.jar sendVerificationEmail $name $email $comments");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:50:48+00:00Added an answer on June 1, 2026 at 5:50 am

    You need to add the jar file containing the javax.mail… classes to your command:

    For example the following will add the current directory (.) and javax.jar to the classpath:

    (linux)   java -classpath .:javax.jar com.me.MyMailClient
    (windows) java -classpath .;javax.jar com.me.MyMailClient
    

    javax.jar is not what it will be called, that’s just to show you where you’d put it. To find out where Eclipse is getting the javax.mail.* items, look at your Project->Properties->Build Path->Libraries tab. One of the jars listed there is what you need (you can see the contents of jars by unzipping). It might be called mail.jar, j2ee.jar, javamail.jar – there are a few different likely candidates. Since your test app is simple it should have few dependencies so you’ll be able to spot it easily.

    You will need to put a copy of this jar file near run script (the above example assumes it is in the same directory as you are running the java command).

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created Excel Sheet using Java program. It works fine. My problem is,
I have to refactor a Java program created with Eclipse RCP. My predecessor handed
I am creating a simple reporting program using java and iReport (from jasper), which
Am trying to implement a Java program which sends an Apple Push Notification to
I have a created a simple applet which sends mail by using smtp.gmail.com on
I created a hello world java program and use lauch4j to convert executable jar
I have recently just created Java project using Eclipse that requires 2 JAR files
i have a java chat server & client, that works fine. I made a
I am new to java programming. I have a program which I wrote to
I recently created a Java frontend for a PHP web-service which uses PHPs SoapServer.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.