Google App Engine Java - javax.servlet source files - java

Using Eclipse (juno) and GAE plugin, I've compiled and ran the "guestbook" example (https://developers.google.com/appengine/docs/java/gettingstarted/creating) without any problem.
Both of the class of the example extend "HttpServlet" class of javax.servlet.http package.
I'd like to see the source code (and javadoc) of this class and of the other class of the package (and super package), but I can't figure out where they are.
They are not in
Program Files\eclipse-jee-juno-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.0\appengine-java-sdk-1.7.0\src
(I've tried all of the files in there)
Binary files should be in servlet-api.jar in
Program Files\eclipse-jee-juno-win32\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.7.0\appengine-java-sdk-1.7.0\lib\shared
I've googled a lot without success.
Anybody knows where to find sources of javax.servlet package?
Thanks a lot.

The sources for javax classes are included with Java EE distributions and not the App Engine SDK. If you can't find a local Java EE distribution, you can try downloading the sources here, and referencing them from within Eclipse.

Project properties -> configure build path -> libraries -> drop down arrow of App Engine SDK-> drop down arrow of servlet-api.jar -> click javadoc location -> click edit -> enter javadoc URL : http://docs.oracle.com/javaee/6/api/

Related

Visual studio code cannot find java libraries

I've setup a Java project in Visual Studio Code. I installed previously a few java extensions :
and I can create a program that does Hello World.
In a folder called lib inside the project folder, I copied some jars (lwjgl3) and, although are shown by intellisense when I try to import them, I have an error that says it cannot find the package :
Anything I missed ?
You need to add the jar to your classpath. The classpath is something used by java to find the libraries your program uses. Java looks in each folder/jar archive to find the class files, because it would be slow if it searched every directory on your computer. See this question: What is a classpath and how do I set it?
Add a reference to the package in the following way.
Click the plus sign to the right of Referenced Libraries under the JAVA PROJECTS panel
Select the .jar file in the pop-up window.

Codename One - Maven Project in Eclipse unable to generate new class

I have a new Android project that I am trying to build with Maven.
I was able to download and import the project in Eclipse, but I am unable to generate a new class inside the the src directory.
The warning I get from File -> New -> Class is : Source folder is not a Java project.
I found a couple of solutions on the internet, saying that it is necessary to include Java from the project facets, but there is no Java option on the tab.
Any solution to this? I am working on Arch Linux.
The solution is adding the Maven Java EE plugin to Eclipse. I found this by typing "facets" in the Market Place search field. This plugin came up and I gave it a go. Luckily, it worked.
After this, you can find several options in project facets. Choose Java :
Properties -> Project Facets -> Java
This site here pointed me into the right direction and explains the process in more detail: Source Folder is not a Java Project

Unable to view complete java source code in IntelliJ

Earlier I used Eclipse. Recently I have started using IntelliJ. I found that the IntelliJ equivalent of Eclipse keyboard shortcut F3 (view source) is F4.
But, when I use that I get the source in the following format.
It does not show complete source, i.e method implementation is not being shown. I have placed src.zip in the java sdk folder where Java is installed. I have added the src.zip in the project libraries too. In eclipse I can just attach source if it can't find one.
I have seen answers of relevant questions but couldn't follow. So,
How to attach the Java source in IntelliJ?
Detailed answer will be appreciated.
Thanks in advance.
Source is found in JDK folder, example - C:\Program Files\Java\jdk1.7.0_25\src.zip. JDK must be downloaded first, of course.
You should attach your source code to your project, get into Project Structure, click Global Libraries, add the source code jar, usually end with sources.jar, now you can see the source code.
you can see the Sources and JavaDocs under the Classes.
Found the answer.
Press ctrl + shift + alt + s
Select SDKs under platform settings.
On the right hand side there will be Sourcepath tab
Add the downloaded src.zip of java to the sourcepath
You can also add the API documentation under the Documentation Path in the same way by adding the downloaded API docs
I found I had to add the dependency jars under the model: i.e.
project structure ->
project settings ->
Modules (select the module where it has problem) ->
Dependencies (on the right handside pane) ->
click "+" ->
library -> then select all the libraries i needed (even though it is available at the root of my sbt project, i had to do this for the module i am interested).
also, i kept the library dependency at the build.sbt to be 'compile' scope instead of 'provided'. but sometime you want your dependency to be provided only (such as spark, or hadoop, in this situation)

How do you import and use existing libraries in Eclipse?

I'm Visual Studios / C#, you can simply add a reference to a DLL file and then just use that namespace. I'm starting to dig into Android development and want to use the SimpleFTP library. Downloaded the .jar file, went to File --> Import and now I've got SimpleFTP.class and SimpleFTP.java in org\jibble\simpleftp in my Package Explorer.
But if I try to import org.jibble.simpleftp; it says it cannot be resolved. What have I done wrong?
I was hoping I could just start typing as if I had properly imported the library and it'd figure out how to correct my package, but no such luck =[
There are at least three solutions:
If you have the source code, you can place it under your src folder directly in your project.
If you have the source code, you can create an Android Library Project with the source code and connect your Android app projec to the library project.
If you have a JAR file, you can place it in the libs folder of your proejct.
Project -> Properties -> Java Path -> Libraries. There you can add your existing libraries, in several formats (jar, .zip, etc.).
Right click on your project and add build path

Eclipse Not Finding Classes added to the build Path (Java Dynamic Web Project)

I am taking over a web project from my school. I am trying to deploy the project in eclipse. The project uses a group of libraries (Namely javax.mail.* , com.sun.mail.*, org.joda.* and org.apache.*). The project can not compile because it is unable to locate these. I have them in the src folder and then added the three top level folders/packages to the build path. The import statements work. But getting the joda.time.CLASSXYZ does not work (Then I instantiate the class CLASSXYZ). (The error is "The type org.joda.time.base.BaseDateTime cannot be resolved. It is indirectly referenced from required .class files" the import was joda.time.* so the class should have been imported)
I've looked at the other threads and most of them just explain how to add folders to the build path. I have Apache tomcat set up with eclipse. It works with other projects that I have deployed.
This problem has gotten pretty frustrating as its preventing me from starting the project. Any help you be much appreciated.
Cheers
Unless you use maven you need to download additional libraries:
javax.mail: http://www.oracle.com/technetwork/java/javamail/index.html (also included in Java EE)
org.apache http://commons.apache.org/
org.joda http://joda-time.sourceforge.net/
I suggest to place them in a folder 'lib' and add the jar-files to your build class path. (context menu on your project).
The other threads you mentioned are pointing you in the right direction, and provide a good practice to get in to (especially once you start having more than one project running in your eclipse ide).
So right click project - Build Path - Configure Build Path... , then in the Libraries tab, click Add External JARs and add in the jar for org.joda from the link in the other answer here. This way you can have all your external jar libraries in one spot and reuse them across multiple projects. There's also about a dozen different ways to do the same thing in eclipse, but this is the most direct I think. I'm on version Helios (your's might be slightly different). I try not to use source files of external code libraries unless I want to play around, debugging their code - not a bad thing to do - but I never have the time to spare for that.
Also I'd double check that the other libraries you mentioned aren't being automatically linked in or included as part of the JRE system library. Especially if you are setup in a Dynamic Web Project, it would surprise me if org.apache wasn't already there... but I could easily be wrong there, have been many times before & eclipse was usually involved ;-)

Categories