Steve Janvrin

Greenhorn
+ Follow
since Feb 10, 2005
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Janvrin

Can someone point me to the solutions for the Sharpen Your Pencil exercises for the second half of Head First Java, first edition?

Thanks.
16 years ago
I'm attempting to run the program from chapter 3 of Head First Servlets & JSP, and I get the following error. My environment variables are set to:

Classpath = C:\j2SDK1.4.2_07\bin;C:\j2SDK1.4.2_07\lib\tools.jar;C:\MyProjects\beerV1\src;C:\Tomcat\common\lib\servlet-api.jar

Java Home = C:\j2sdk1.4.2_07

Catalina Home = C:\Tomcat

Tomcat Home = C:\Tomcat

Any assistance is greatly appreciated.

Steve.

*********output follows********

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.example.web.BeerSelect.doPost(BeerSelect.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.example.web.BeerSelect.doPost(BeerSelect.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28
16 years ago
I'm attempting to run the program from chapter 3 of Head First Servlets & JSP, and I get the following error. My environment variables are set to:

Classpath = C:\j2SDK1.4.2_07\bin;C:\j2SDK1.4.2_07\lib\tools.jar;C:\MyProjects\beerV1\src;C:\Tomcat\common\lib\servlet-api.jar

Java Home = C:\j2sdk1.4.2_07

Catalina Home = C:\Tomcat

Tomcat Home = C:\Tomcat

Any assistance is greatly appreciated.

Steve.

*********output follows********

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:97)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:346)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.example.web.BeerSelect.doPost(BeerSelect.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:106)
org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:935)
org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.example.web.BeerSelect.doPost(BeerSelect.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28
16 years ago
Can someone tell me why the xsi:schemaLocation below is flagged as invalid by XMLspy, given that the entire file is copied line for line out of the Head First Servlets & JSP book, page 77? I've also copied this line (starting at http) into a browser and it get to the xsd fine.

Thanks,

Steve Janvrin.


<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<servlet>

<servlet-name>Ch3 Beer</servlet-name>

<servlet-class>com.example.web.BeerSelect</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Ch3 Beer</servlet-name>

<url-pattern>/SelectBeer.do</url-pattern>

</servlet-mapping>

</web-app>
Thanks - I would have thought that the compiler would have caught that, but I guess not.

Steve.
16 years ago
When I run this code the value of the boolean snare is correctly reset from true to false, but the if test ignores this and executes the code inside the if test.

This is the code as shown on page 44 of Head First Java, so it should work.

Please assist.

Steve Janvrin.

class DrumKit {
boolean tophat = true;
boolean snare = true;

void playtophat() {
System.out.println("ding ding da-ding");
}

void playsnare() {
System.out.println("bang bang ba-bang");
}
}

class DrumKitTestDrive {
public static void main(String[] args) {

DrumKit d = new DrumKit();

d.playsnare();
d.playtophat();
d.snare = false;

if (d.snare == true); {
d.playsnare();
}
}
}
16 years ago
Matt - thanks for the clarification. I did indeed have the name of the file and the class name as the same thing.

I got the program to run successfully using Kashif's approach. Thanks again for the help.

Steve.
16 years ago
I saved the file as .java. I'll try the suggestions and post again if I still have problems. Thanks for the quick replies.

Steve.
16 years ago
I just started using the Head First Java book to learn Java. I created my source file using the code from page 7. It is:

public class MyFirstApp {

public static void main (String[] args) {
System.out.println ("I Rule!");
System.out.println ("The World");
}
}

I don't see any errors, but I get the following when I attempt to run it:

Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp

Please advise.

Also - am I in the right place for questions this basic?

Steve Janvrin.
16 years ago