Error building a simple java file
I downloaded JDeveloper 10g. I can build the Workspace and the project, but when I tray to build a Java Class I recive this error :
Invalidad Base Class
"java.lang.object" is not a valid base class for this operation.
I have installed java a work fine, I can build and run programs with JCreator, put a cant work with JDeveloper.
Some idea?
Thanks.
I did download 10.1.2 full version and I'm using JDK 1.4.2_08. Y try on another machine and work fine but not work on my machine I use Windows XP with service pack 2.
Similar Messages
-
What's wrong with this simple java file
I am learning java input methods. When I tried to compile the below simple java file, there were two errors.
import java.io.*;
public class MainClass {
public static void main(String[] args) {
Console console = System.console();
String user = console.readLine("user: ");
System.out.println(user);
}The compiler errors:
h:\java\MainClass.java:5: cannot resolve symbol
symbol : class Console
location: class MainClass
Console console = System.console();
^
h:\java\MainClass.java:5: cannot resolve symbol
symbol : method console ()
location: class java.lang.System
Console console = System.console();
^
2 errors
Could anyone take a look and shed some lights on this?I have changed to "import java.io.Console;" but this below errors:
h:\java\MainClass.java:1: cannot resolve symbol
symbol : class Console
location: package io
import java.io.Console;
^
h:\java\MainClass.java:5: cannot resolve symbol
symbol : class Console
location: class MainClass
Console console = System.console();
^
h:\java\MainClass.java:5: cannot resolve symbol
symbol : method console ()
location: class java.lang.System
Console console = System.console();
^
3 errors
----------- -
Problem compiling a simple java file
Hi,
When I try to compile the following simple java file
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HowdyServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<html>");
out.println("<body>");
out.println("<center><h1>Hi</h1></center>");
out.println("</body>");
out.println("</html>");
at the command prompt as follows
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac -classpath
"C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip" *.java
Or
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac *.java
Or
C:\Shared\CBT\Java 2 JSP and Java Servlets\03\servlet1>javac HowdyServlet.java
I get the following errors and I cannot compile this java file -
HowdyServlet.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
HowdyServlet.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HowdyServlet.java:5: cannot find symbol
symbol: class HttpServlet
public class HowdyServlet extends HttpServlet {
^
HowdyServlet.java:6: cannot find symbol
symbol : class HttpServletRequest
location: class HowdyServlet
public void doGet(HttpServletRequest request,
^
HowdyServlet.java:7: cannot find symbol
symbol : class HttpServletResponse
location: class HowdyServlet
HttpServletResponse response)
^
HowdyServlet.java:8: cannot find symbol
symbol : class ServletException
location: class HowdyServlet
throws IOException, ServletException {
^
6 errors
I have installed the latest JEE 5 SDK on Win XP Home. I have the following variable set as follows,
CLASSPATH = .;C:\Program Files\Java\j2re1.4.2_03\lib\ext\QTJava.zip
PATH = C:\Sun\AppServer\jdk\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\QuickTime\QTSystem;C:\Sun\AppServer\lib\ant\bin
ANT_HOME = C:\Sun\AppServer\lib\ant
I have spent hours scratching my head but don?t have a clue. I was wondering if you have any idea as why I might be getting these errors.
Thank you for your time.
GreenHello, did you read the answers?
You have to put j2ee.jar or servlet-api.jar in your classpath. Those JAR files are included in the Java EE package somewhere. Remove the QTJava.zip junk from the classpath.
If you don't know what the classpath is and how to set it, read this:
Setting the class path
How Classes are Found
And I'll repeat what the others say: if you are very new to Java, then Java EE will probably be way over your head. First learn the language and the standard API. If you understand that well, start with Java EE. Or do you already know what servlets are, and that you need a servlet container to run them, and how to deploy them etc.? -
How to test the simple .java file in cactus
dear friends,
i have use the junit first time .And i am working in weblogic8.1 so i have use cactus .But i face the problem to use it.
1. how to test the simple .java file in cactus.
2.how to run the cactus in weblogic 8.1.Hi,
It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
Cheers,
Shane -
Error in Running of java file(while connecting for SAP BW SERVER)
Hi,
Any one could be help regarding the following error message I am getting on running of Java File?
C:\>cd C:\j2sdk1.4.2_04\bin
C:\j2sdk1.4.2_04\bin>Set Classpath=%classpath%;C:\j2sdk1.4.2_04\bin\jco\com\sap\
mw\jco\jco.jar;
C:\j2sdk1.4.2_04\bin>javac DevelopmentQueue.java
C:\j2sdk1.4.2_04\bin>java DevelopmentQueue
<u><b>200
JCO.init: Unsupported Java VM version 1.4.2_04 detected</b></u>.
C:\j2sdk1.4.2_04\bin>java -version
java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
C:\j2sdk1.4.2_04\bin>Hi Ganesh,
Thanks for reply.I tried the classpath you mentioned,Still I am getting the same error.
C:\>cd C:\j2sdk1.4.2_04\bin
C:\j2sdk1.4.2_04\bin>Set Classpath=%Classpath%;.;C:\j2sdk1.4.2_04\bin\jco\com\sa
p\mw\jco\jco.jar;
C:\j2sdk1.4.2_04\bin>javac DevelopmentQueue.java
C:\j2sdk1.4.2_04\bin>java DevelopmentQueue
<b>200
JCO.init: Unsupported Java VM version 1.4.2_04 detected.</b>
C:\j2sdk1.4.2_04\bin>
If I want to upgrade JDK Version to 1.4.2_05 or above, pls mail me the necessary URL Link to download it.
I appreciate your early mail.
Kind regards
CSM REDDY -
Error while compiling QuoteRenderer.java file
Currently I am working on Quotes customizations. As part of customizations, I need to modify the seeded java file (i.e., $JAVA_TOP/oracle/apps/qot/util/QuoteRenderer.java)
Since i have only class files, I have decompiled the class file using JAD and modified the code and placed in the same path and tried to compile. Then I am getting the below errors: [I am getting the same errors even if i placed the decompiled file without any modifications]. Can you help in resolving this issue.
Errors:
oracle/apps/qot/util/QuoteRenderer.java:16: package javax.servlet.jsp does not exist
import javax.servlet.jsp.JspWriter;
^
oracle/apps/qot/util/QuoteRenderer.java:17: package javax.servlet.jsp does not exist
import javax.servlet.jsp.PageContext;
^
oracle/apps/qot/util/QuoteRenderer.java:127: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
public static void loadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, int i)
^
oracle/apps/qot/util/QuoteRenderer.java:664: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
public static void loadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s, String s1)
^
oracle/apps/qot/util/QuoteRenderer.java:775: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
public static void loadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s)
^
oracle/apps/qot/util/QuoteRenderer.java:838: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
private static void partialLoadQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, int i)
^
oracle/apps/qot/util/QuoteRenderer.java:916: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
public static void loadExpandList(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext)
^
oracle/apps/qot/util/QuoteRenderer.java:975: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
public static void renderQuoteLines(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s, String s1)
^
oracle/apps/qot/util/QuoteRenderer.java:1652: cannot find symbol
symbol : class PageContext
location: class oracle.apps.qot.util.QuoteRenderer
public static void renderQuoteLineSmry(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, PageContext pagecontext, String s)
^
oracle/apps/qot/util/QuoteRenderer.java:386: reference to QuoteException is ambiguous, both method QuoteException(java.lang.String,java.lang.Object[]) in oracle.apps.qot.core.QuoteException and method QuoteException(java.lang.String,java.lang.String) in oracle.apps.qot.core.QuoteException match
throw new QuoteException(s2, null);
^
oracle/apps/qot/util/QuoteRenderer.java:982: cannot find symbol
symbol : class JspWriter
location: class oracle.apps.qot.util.QuoteRenderer
JspWriter jspwriter = pagecontext.getOut();
^
oracle/apps/qot/util/QuoteRenderer.java:1659: cannot find symbol
symbol : class JspWriter
location: class oracle.apps.qot.util.QuoteRenderer
JspWriter jspwriter = pagecontext.getOut();
^
Note: oracle/apps/qot/util/QuoteRenderer.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.Hi,
You need to add librabry for j2ee-1.4.jar in your classpath this can be found under JSP Runtime library in your jdevhome\jdevbin folder.
~Ankul -
Compile error with IDLJ generated java files.
When compiling the IDLJ generated java files, javac is not able to recognize org.omg.CORBA.ObjectHelper
classs. Looks like the import is not finding this class.
I have located these classes in rt.jar but including this jar in CLASSPATH gives
a version '48.0' is too recent error.
Thanks
RameshPLEASE IGNORE THIS MESSAGE. I HAVE RESOLVED THIS ISSUE.
"Ramesh Nadella" <[email protected]> wrote:
>
When compiling the IDLJ generated java files, javac is not able to recognize
org.omg.CORBA.ObjectHelper
classs. Looks like the import is not finding this class.
I have located these classes in rt.jar but including this jar in CLASSPATH
gives
a version '48.0' is too recent error.
Thanks
Ramesh -
Error while compiling VO java files
I am getting following error while compiling VO java class in my instance
Exception in thread "main" java.lang.ClassFormatError: com.sun.tools.javac.main.Main (erroneous method access flags)
at JvClassReader.throw_class_format_error(byte) (/usr/lib/libgcj.so.5.0.0)
at JvClassReader.handleMethod(int, int, int, int) (/usr/lib/libgcj.so.5.0.0)
at JvClassReader.read_methods() (/usr/lib/libgcj.so.5.0.0)
at JvClassReader.parse() (/usr/lib/libgcj.so.5.0.0)
at JvDefineClass(java.lang.Class, byte[], int, int) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.defineClass(java.lang.ClassLoader, java.lang.String, byte[], int, int, java.security.ProtectionDomain) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.ProtectionDomain) (/usr/lib/libgcj.so.5.0.0)
at java.security.SecureClassLoader.defineClass(java.lang.String, byte[], int, int, java.security.CodeSource) (/usr/lib/libgcj.so.5.0.0)
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
at JvFindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at JvBytecodeVerifier.verify_instructions_0() (/usr/lib/libgcj.so.5.0.0)
at JvVerifyMethod(_Jv_InterpMethod) (/usr/lib/libgcj.so.5.0.0)
at JvPrepareClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at JvWaitForState(java.lang.Class, int) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.linkClass0(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
at JvThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0)
at JvRunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0)
at __libc_start_main (/lib/tls/libc-2.3.4.so)
Please advise me to get rid of this one.
-- Manoj
Edited by: 856261 on May 4, 2011 12:55 AMI created custom VO and files in my local JDev and it is working properly.
I wanna migrate it to actual instance.So my question is is it mandatory to compile custom java file in application server or i can use same which i used in my local machine(windows)?
-- Manoj -
Error when compiling the Java file
Hi I have created a jsp program that uses the java files. i have jboss installed. when i compile the java file it gives compilation error saying that javax.servlet.jsp.tagext.TagSupport not found.
Although when i installed the Tomcat seperately i did not get any compilation error. can anyone tell me how to get out of this problem when Tomcat is not installed seperately.
Thanks,
RakeshHi
I think these errors are due to incorrect classpath settings.While compiling HelloHome ..Helloremote must be in classpath.Also if u have packaged them u must be in the package root during compilation ie if uor remote & home interface is in a package called "ejbserver"
then while compiling u must be in the folder above ejbserver & compile command is
javac .\ejbserver\*.java
If uor home & remote interface is in different folder check wheather u have imported the remote interface inside home interface file. -
Error While Compiling Seeded Java Files
Error(12,8): class oracle.apps.gl.jahe.server.FndFlexValidationQualifierEOImpl should be declared abstract; it does not define method setLastUpdateLogin(oracle.jbo.domain.Number) in class oracle.apps.fnd.framework.server.OAEntityImpl
Error(10,8): class oracle.apps.gl.jahe.server.GlAheDetailRangeEOImpl should be declared abstract; it does not define method setLastUpdateLogin(oracle.jbo.domain.Number) in class oracle.apps.fnd.framework.server.OAEntityImpl
Error(12,8): class oracle.apps.gl.jahe.server.GlLookupEOImpl should be declared abstract; it does not define method setLastUpdateLogin(oracle.jbo.domain.Number) in class oracle.apps.fnd.framework.server.OAEntityImpl
Have copied one of the java code that failed? any Suggestions?
package oracle.apps.gl.jahe.server;
import oracle.apps.fnd.framework.server.OAEntityImpl;
import oracle.jbo.server.EntityDefImpl;
import oracle.jbo.server.AttributeDefImpl;
import oracle.jbo.domain.Number;
import oracle.jbo.domain.Date;
import oracle.jbo.Key;
// --- File generated by Oracle Business Components for Java.
public class FndFlexValidationQualifierEOImpl extends OAEntityImpl
protected static final int FLEXVALUESETID = 0;
protected static final int IDFLEXAPPLICATIONID = 1;
protected static final int IDFLEXCODE = 2;
protected static final int SEGMENTATTRIBUTETYPE = 3;
protected static final int VALUEATTRIBUTETYPE = 4;
protected static final int ASSIGNMENTDATE = 5;
private static oracle.apps.fnd.framework.server.OAEntityDefImpl mDefinitionObject;
* This is the default constructor (do not remove)
public FndFlexValidationQualifierEOImpl()
* Retrieves the definition object for this instance class.
public static synchronized EntityDefImpl getDefinitionObject()
if (mDefinitionObject == null)
mDefinitionObject = (oracle.apps.fnd.framework.server.OAEntityDefImpl)EntityDefImpl.findDefObject("oracle.apps.gl.jahe.server.FndFlexValidationQualifierEO");
return mDefinitionObject;
* Gets the attribute value for FlexValueSetId, using the alias name FlexValueSetId
public Number getFlexValueSetId()
return (Number)getAttributeInternal(FLEXVALUESETID);
* Sets <code>value</code> as the attribute value for FlexValueSetId
public void setFlexValueSetId(Number value)
setAttributeInternal(FLEXVALUESETID, value);
* Gets the attribute value for IdFlexApplicationId, using the alias name IdFlexApplicationId
public Number getIdFlexApplicationId()
return (Number)getAttributeInternal(IDFLEXAPPLICATIONID);
* Sets <code>value</code> as the attribute value for IdFlexApplicationId
public void setIdFlexApplicationId(Number value)
setAttributeInternal(IDFLEXAPPLICATIONID, value);
* Gets the attribute value for IdFlexCode, using the alias name IdFlexCode
public String getIdFlexCode()
return (String)getAttributeInternal(IDFLEXCODE);
* Sets <code>value</code> as the attribute value for IdFlexCode
public void setIdFlexCode(String value)
setAttributeInternal(IDFLEXCODE, value);
* Gets the attribute value for SegmentAttributeType, using the alias name SegmentAttributeType
public String getSegmentAttributeType()
return (String)getAttributeInternal(SEGMENTATTRIBUTETYPE);
* Sets <code>value</code> as the attribute value for SegmentAttributeType
public void setSegmentAttributeType(String value)
setAttributeInternal(SEGMENTATTRIBUTETYPE, value);
* Gets the attribute value for ValueAttributeType, using the alias name ValueAttributeType
public String getValueAttributeType()
return (String)getAttributeInternal(VALUEATTRIBUTETYPE);
* Sets <code>value</code> as the attribute value for ValueAttributeType
public void setValueAttributeType(String value)
setAttributeInternal(VALUEATTRIBUTETYPE, value);
* Gets the attribute value for AssignmentDate, using the alias name AssignmentDate
public Date getAssignmentDate()
return (Date)getAttributeInternal(ASSIGNMENTDATE);
* Sets <code>value</code> as the attribute value for AssignmentDate
public void setAssignmentDate(Date value)
setAttributeInternal(ASSIGNMENTDATE, value);
// Generated method. Do not modify.
protected Object getAttrInvokeAccessor(int index, AttributeDefImpl attrDef) throws Exception
switch (index)
case FLEXVALUESETID:
return getFlexValueSetId();
case IDFLEXAPPLICATIONID:
return getIdFlexApplicationId();
case IDFLEXCODE:
return getIdFlexCode();
case SEGMENTATTRIBUTETYPE:
return getSegmentAttributeType();
case VALUEATTRIBUTETYPE:
return getValueAttributeType();
case ASSIGNMENTDATE:
return getAssignmentDate();
default:
return super.getAttrInvokeAccessor(index, attrDef);
// Generated method. Do not modify.
protected void setAttrInvokeAccessor(int index, Object value, AttributeDefImpl attrDef) throws Exception
switch (index)
case FLEXVALUESETID:
setFlexValueSetId((Number)value);
return;
case IDFLEXAPPLICATIONID:
setIdFlexApplicationId((Number)value);
return;
case IDFLEXCODE:
setIdFlexCode((String)value);
return;
case SEGMENTATTRIBUTETYPE:
setSegmentAttributeType((String)value);
return;
case VALUEATTRIBUTETYPE:
setValueAttributeType((String)value);
return;
case ASSIGNMENTDATE:
setAssignmentDate((Date)value);
return;
default:
super.setAttrInvokeAccessor(index, value, attrDef);
return;
* Creates a Key object based on given key constituents
public static Key createPrimaryKey(Number flexValueSetId, Number idFlexApplicationId, String idFlexCode, String segmentAttributeType, String valueAttributeType)
return new Key(new Object[] {flexValueSetId, idFlexApplicationId, idFlexCode, segmentAttributeType, valueAttributeType});
}Common error, you need to add LASTUPDATELOGIN definitino to your EO...
protected static final int FLEXVALUESETID = 0;
protected static final int IDFLEXAPPLICATIONID = 1;
protected static final int IDFLEXCODE = 2;
protected static final int SEGMENTATTRIBUTETYPE = 3;
protected static final int VALUEATTRIBUTETYPE = 4;
protected static final int ASSIGNMENTDATE = 5;
protected static final int LASTUPDATELOGIN = 6;
public Number getLastUpdateLogin()
return (Number)getAttributeInternal(LASTUPDATELOGIN);
public void setLastUpdateLogin(Number value)
setAttributeInternal(LASTUPDATELOGIN, value);
To protected Object getAttrInvokeAccessor...
case LASTUPDATELOGIN:
return getLastUpdateLogin();
To protected void setAttrInvokeAccessor ...
case LASTUPDATELOGIN:
setLastUpdateLogin((Number)value);
return;
This should resolve your problem.
Edited by: sreese on May 15, 2009 4:32 PM -
Building a simple java portlet
Hi:
i have a java application with some forms, textareas, checkboxes, etc. i need to put this application into a portal page. do i have to rewrite all the code? what is the structure of a java portlet application? i mean, main function, renderBody, etc. Anybody can give the most simple full example of a java application portlet?
Thx.
Regards. Urko.Hi Erik,
Thanks for your help. I found the answer. The servlet 2.3 web application version must be used instead of version 2.4 when building the application.
Thanks Erik -
Error Executing a simple class file
Exception in thread "main" java.lang.UnsupportedClassVersionError: Arith (Unsupp
orted major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)You compiled with a version 6 or 7 javac, but you're trying to run it with a lower version java.exe.
-
Error while compiling java file using J2SE 1.5.0
Dear Sir,
I'm getting the following error while compiling the java file.The code is also given.
package test;
public class TestRowSet {
public TestRowSet() {
"TestRowSet.java": cannot access java.lang.Object,bad class file: D:\Program Files\Java\jdk1.5.0\jre\lib\rt.jar\java\lang\Object.class,class file has wrong version 49.0, should be 48.0,Please remove or make sure it appears in the correct subdirectory of the classpath. at line 4, column 1
Please help me out.
--Suketu Naik.But I'm compiling within "Borland JBuilder 9.0". I've
set the JDK path of the current project to point to
the path of JDK 1.5.0 . I've also tried to compile at
command prompt with "javac". I'm getting the same
error of "Undefinedclassloader" with long StatckTrace.
I don't know anything about JBuilder either. If you use the command prompt and enter the full path to the 1.5 javac.exe then that will prove whether the issue is using an older javac or not. For example "c:\j2sdk1.5.0_01\bin\javac HelloWorld.java" -
I am to create a link verification program -- a simple java file with the database connection & some business logic and a JSP page that instantiates the my java file. It won't work. Everytime I run the jsp page, it gives me java.lang.NullPointerException. Can anyone give me some directions? The web server I am using is JRun.
Thank you
Below are my code:
JSP Page:
<%-- Verify Links
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="java.sql.*" %>
<%@ page import="java.net.*" %>
<%@ page import="pro.*" %>
<html>
<head>
<title>Results</title>
</head>
<body>
<%
try{
LinkConnection newconn = new LinkConnection();
newconn.initialize();
newconn.query();
newconn.close();
}catch (ClassNotFoundException cnfe)
out.println(cnfe);
catch (SQLException sqle)
out.println(sqle);
catch (NullPointerException npe)
out.println(npe);
%>
</body>
</html>
Java Code:
package pro;
import java.io.*;
import java.sql.*;
import java.net.*;
public class LinkConnection {
Connection con;
ResultSet RS;
Statement Stmt;
public void initialize() throws SQLException, ClassNotFoundException
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("XXXX", "XXXX", "XXXX");
public void query() throws SQLException
Statement Stmt=con.createStatement();
String strSQL="Select guideline_name, guideline_url from pgt_guidelines";
ResultSet RS=Stmt.executeQuery(strSQL);
while (RS.next())
String guidelinename = RS.getString("guideline_name");
String guidelineurl = ("http://" + RS.getString("guideline_url"));
try {
URL url = new URL(guidelineurl);
HttpURLConnection link=(HttpURLConnection)url.openConnection();
System.out.println("<font color='blue'>");
System.out.println(guidelinename);
System.out.println("<br>");
System.out.println(guidelineurl);
System.out.println("</font>");
System.out.println("<font color='red'>");
System.out.println(link.getResponseCode());
System.out.println("</font>");
System.out.println("<br />");
}catch (Exception e)
{System.out.println("<font color='yellow'>Error Link </font>")
public void close() throws SQLException {
RS.close();
Stmt.close();
con.close();i'm having the same problem, what is the solution to this
A Servlet Exception Has Occurred
java.lang.NullPointerException
at test.Lesson.runSql(Lesson.java:80)
===== Lesson.java file =====
package test;
import java.sql.* ;
import java.io.Serializable;
public class Lesson {
public Lesson( ) { }
//Line 9
public String runSql ( ) {
String browserOutput = "";
Connection sqlca = null;
Statement sqlStatement = null;
ResultSet myResultSet = null;
//Line 16
/* Connect to database, run SQL and produce output */
try {
/* Connection to the database */
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String theDatabase ="jdbc:mysql://localhost/employee";
sqlca = DriverManager.getConnection(theDatabase,"usr","pwd");
//Line 24
/* Construct and execute the sql, positioning before the
first row in the result set */
sqlStatement = sqlca.createStatement();
myResultSet = sqlStatement.executeQuery
//Line 29
("select emp_id, " +
"emp_lname, " +
"city, " +
"state," +
"zip_code, " +
"emp_fname " +
"from employee " +
"where emp_id < 250 " +
"order by emp_lname, emp_fname");
//Line 39
/* Construct the heading for the table */
browserOutput =
"<div align=left>"+
"<table border=0 align=left width=520>" +
"<caption><i><b>" +
"Employee Listing</b></i></caption>" ;
//Line 46
/* Construct the column headings for the table */
browserOutput +=
"<th align=left>Emp_id</th>" +
"<th>First Name</th>" +
"<th>Last Name</th>" +
"<th>City</th>" +
"<th>State</th>" +
"<th>Zip</th>" ;
//Line 55
/* Move to next row and & its contents to the html output */
while(myResultSet.next()) {
browserOutput += "<TR><TD>" +
myResultSet.getObject("emp_id").toString() + "</TD><TD>" +
myResultSet.getObject("emp_fname").toString()+"</TD><TD>" +
myResultSet.getObject("emp_lname").toString() + "</TD><TD>" +
myResultSet.getObject("city").toString() + "</TD><TD>" +
myResultSet.getObject("state").toString() + "</TD><TD>" +
myResultSet.getObject("zip_code").toString() + "</TD></TR>" ;
//Line 66
}//end of while
sqlStatement.close();
sqlca.close();
}//end of try
catch (SQLException e) {
//Line 72
browserOutput = " Error: SQLException: " + e.getMessage();
browserOutput= " Error: SQLState: " + e.getSQLState();
browserOutput= " VendorError: " + e.getErrorCode();
}//end of SQLException
catch (Exception e) {
browserOutput = " Error: JDBC Class creation: " + e.getMessage();
}//end of Exception
/**Line 80**/ finally {
try { sqlca.close(); }
catch(SQLException e) {
browserOutput = " Error: Closing connection: " + e.getMessage();
}//end of finally
/* Complete the html and return it to the Java Server Page */
browserOutput += "</table>" + "</div>" ;
return browserOutput;
} //end of runSql
}//end of Lesson -
Trouble compiling java files inside the packages.
Hello I have a question in Java when compiling with packages. Can anyone Help??
My 2 java files BeerSelect2.java & BeerExpert.java are in packages com.example.web & com.example.model respectively.
C:\MyProjects\beerV1\src\com\example\web\BeerSelect2.java
and
C:\MyProjects\beerV1\src\com\example\model\BeerExpert.java
I have compiled the BeerExpert.java in the model package.(ie the class file for BeerExpert is in the com.example.model package.)
My BeerSelect2 file which is inside the web folder is like this
package com.example.web;
import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class BeerSelect2 extends HttpServlet
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("Beer Selection Advice<br>");
String c=request.getParameter("color");
out.println("<br> Got Beer color "+c);
BeerExpert be=new BeerExpert();
List result=be.getBrands(c);
response.setContentType("text/html");
out.println("BEER SELECTION ADVICE <br>");
Iterator it=result.iterator();
while(it.hasNext())
out.print("<br> try: "+it.next());
This shows 3 comile errors.
& the BeerExpert.java file which is in the model folder is like this:
package com.example.model;
import java.util.*;
public class BeerExpert
public List getBrands(String color)
List brands=new ArrayList();
if(color.equals("amber"))
brands.add("Jack Amber");
brands.add("Red Moose");
else
brands.add("Jale pale Ale");
brands.add("Gout Stout");
return (brands);
This compiles fine in the model folder.
Now when I'm trying to compile my BeerSelect2.java in the 'web' folder in which I'm trying to import the com.example.model.* which is as follows
C:\MyProjects\beerV1\src\com\example\web>javac BeerSelect2.java
which gives 3 errors like this
BeerSelect2.java:3: package com.example.model does not exist
import com.example.model.*
^
BeerSelect2.java:22:cannot find symbol
symbol: class BeerExpert
location: class com.example.web.BeerSelect2.
BeerExpert be=new BeerExpert();
^
BeerSelect2.java:22:cannot find symbol
symbol: class BeerExpert
location: class com.example.web.BeerSelect2.
BeerExpert be=new BeerExpert();
^
Can anyone help???Since the classes are part of the com.example.web and com.example.model packages the most straight forward way to compile is from the folder containing "com". Assuming you want the resulting .class files to be in the same folders are their associated .java source files:
C:\MyProjects\beerV1\src\> javac -cp . com\example\model\BeerExpert.java
C:\MyProjects\beerV1\src\> javac -cp . com\example\web\BeerSelect2.javaThe -cp . part is there to set the classpath (the location that the compiler will use to locate java classes) and thereby let the compiler make sense of the import statements.
The presence of "src" in the directory path strongly suggests, however, that the intention is not to have source and class files end up in the same directory. If this is the case read up on the syntax of the http://download.oracle.com/javase/6/docs/technotes/tools/windows/java.html (java.exe) and http://download.oracle.com/javase/6/docs/technotes/tools/windows/javac.html (javac.exe) commands. (paying attention to how searching for types is done). Also read up on any documentation you were given for building the application (if you are modifying something already given).
If you are using an IDE you should say.
Maybe you are looking for
-
Getting error (-1202) when trying to access my wishlist
getting error (-1202) when trying to access my wishlist
-
Multiple PR's generating for same material after MRP
Hi Guru's, As per my business scenario, i am creating project with WBSE, Activities and BOM. By using the reference points, i am transferring the BOM to Project, then executing MRP run. But after MRP run i found that multiple PR's generated for the s
-
Hourly differential backups are too big
Hello, Please let me first apologize if this isn't the correct forum. I'm having a problem that, for the life of me, I can't seem to resolve. To begin with, I'm using MSSQL Server 2012. I created a new MSSQL maintenance plan to perform a full nightl
-
Hi everyone, It seems as if the iPhone features the flash player within Safari. The page www.fandango.com is being used as a demo on the device in Apple's web site and this page has a few Flash banners. They don't seem to be animated on the demo thou
-
How to kick start SAP SRM???
Hi SRM Gurus.., I am basically a Spend management consultant working on Ariba Analysis., now I am planning to move towards SAP SRM. Please give me tips is it is useful to future career and How to start learning SAP SRM. In particularhow to kicki star