I am writing JApplet in Netbeans. My applet is working, so I decide to add servlet because I want to have log in/out. When I added servlet to my project as follows:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
I had the following errors:
error: package javax.servlet does not exist
import javax.servlet.ServletException;
error: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
Apache Tomcat is working.
Add servlet jar to the classpath in your IDE. Your webcontainer will provide it at runtime. You don't have to bundle it in your WAR
I found this solution here
Under Libraries Folder in the Project Window, Right-click and "Add Library...", then choose Java EE web 8 API
Related
I want to import the packages, for example:
import java.io.PrintWriter;
import java.text.DateFormat;
import java.util.Date;
these packages have already existed so it doesn't pop up any error messages.
When I want to import others packages:
import com.businessobjects.rebean.wi.DocumentInstance;
import com.businessobjects.rebean.wi.Prompt;
import com.businessobjects.rebean.wi.Prompts;
import com.businessobjects.rebean.wi.ReportEngine;
import com.businessobjects.rebean.wi.ReportEngines;
import com.crystaldecisions.enterprise.ocaframework.ServiceNames;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.CrystalEnterprise;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.framework.ISessionMgr;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.occa.infostore.IInfoObjects;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.plugin.desktop.folder.IFolder;
It will say "the import cannot be resolved", but where I can get the jar files to resolve these problems?
I tried to search these jar files in the java lib folder but was not able to get them.
Can anyone tell the exact folder path for these jar files, if it is there?
Or where can I download those packages.....
I found the website (https://help.sap.com/doc/javadocs_bip_42/4.2/en-US/bip/en/com/crystaldecisions/sdk/exception/package-summary.html) but I still don't know how to import it......
You'll need rebean.wi.adapter.jar and cecore.jar. They are located in the following directory with BO client or server software is installed:
C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java\lib
Note that these are not available publicly -- you will need to install the software.
I am using eclipse for core java and its working fine. Now I downloaded another eclipse for java ee and I am using tomcat server but in my new eclipse java files are not getting loaded
Below mentioned imports are showing the error of import cannot be resolved while they are working fine in my old eclipse(I think there is some problem with build path ) -
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
While the below-mentioned imports do not show any error-
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.mysql.jdbc.ResultSet;
Sample Image of error:
A package at the top should be used, a deep src sub-directory like: src/aaa/bbb/ccc.
package aaa.bbb.ccc;
import ...
Reason: using the default package (immediately under the root) is actually
never done since java 1.2. For that I find the missing package suspicious.
The following is wrong:
import com.mysql.jdbc.ResultSet;
It should be:
import java.sql.ResultSet;
Reason for JDBC using database vendor specific libraries is bad style.
Entirely sure on a cause for your errors in eclipse I am not sure. A refresh, Alt+F5 might be useful if the error was a fluke.
If the JDK is actually java 9 I would expect import problems too, as then you would need to gather the JDK modules piecewise. That does not seem to be the case here.
Check if you have set the JDKs correctly in your IDE and in the project.
I have downloaded the library
added the library
refreshed the project
imported the library to project
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.params.HttpMethodParams;
However i still get the error
The import org.apache.commons.httpclient can not be resolved
can you please tell what is the problem with it?
I have a file in Java that was given to me that I am trying to edit, however when I hit build in netbeans, I get the errors below. It worked fine until I made the changes. I'm not sure why the jar file would work before, and yet now I can't build it. I'm a noob... How do I get these packages? Thanks.
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:15: error: package org.jsoup does not exist
import org.jsoup.Jsoup;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:16: error: package org.jsoup.nodes does not exist
import org.jsoup.nodes.Document;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:17: error: package org.jsoup.nodes does not exist
import org.jsoup.nodes.Element;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:18: error: package org.jsoup.select does not exist
import org.jsoup.select.Elements;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:19: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:20: error: package org.openqa.selenium does not exist
import org.openqa.selenium.Keys;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:21: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:22: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebElement;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:23: error: package org.openqa.selenium.chrome does not exist
import org.openqa.selenium.chrome.ChromeDriver;
C:\Users\Hendrick Brutsaert\Desktop\scrapers\Investing (1)\Investing\src\investing\InvesterMain.java:24: error: package org.openqa.selenium.interactions does not exist
import org.openqa.selenium.interactions.Actions;
It looks like path for the jsoup.jar and selenium.jar is not located correctly.
First download jsoup.jar from here and selenium.jar from here and add them to libraries of your project.
in netbeans in project window Expand your project and right click on libraries ans select add jar/folder and locate your jsoup.jar and selenium.jar file locations and Add them. Then build the project.
You are supposed to include the third party dependency jars in your project.
https://jsoup.org/download
http://docs.seleniumhq.org/download/
You can download them from here.
Edit your project properties, go to library and add these jars. Should do it.
I have downloaded. using git, the Google I/O app from there website and I can't get it to compile. Android Studio is giving me the error: "the package javax.servlet does not exists" from the following code
package com.google.android.apps.iosched.gcm.server.cron;
import com.google.android.apps.iosched.gcm.server.BaseServlet;
import com.google.android.apps.iosched.gcm.server.db.DeviceStore;
import java.io.IOException;
import java.io.PrintWriter;`
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
How will I be able to install the package?