• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaMail Session cannot be resolved to a type

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I'm working with the following code in Eclipse:


The classpath appears to be fine, and I get no errors in the code. However once try to run that code in Eclipse's internal browser, I get error messages like this:



Eclipse is configured to spot errors immediately, and if I comment out the imports, then I see errors on the lines like #17. When I de-comment the imports, all the errors magically go away, which tells me that to some extent, Eclipse is reading the jar file and importing everything. What's the deal?
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suggestions:

#1: Java code doesn't belong in a JSP. Put this logic into a servlet where you have full control over the imports.
#2: Try it specifying the full class name: javax.mail.Session. It is possible there is another class "Session" being imported from a different package
#3: Watch out for SQL Injection. Use a prepared statement rather than building up a sql string via concatenation.
 
John McClellan
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot I had made this thread. Anyway coming back to it a while after I submitted the initial query, I'm gonna state what had gone wrong. Basically in Eclipse, even if you've got your path/classpath variables all set correctly, a dynamic web project won't work unless you put non-standard jars like the one I was trying to use in <project name>\WebContent\WEB-INF\lib. Earlier I just had the jar somewhere else on my computer, but even setting the path/classpath variables properly, it wouldn't work; you just have to put those things into that specific folder for some reason.
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic