Win a copy of Event Streams in Action this week in the Java in General forum!

Martin Clausen

Greenhorn
+ Follow
since May 15, 2001
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 Martin Clausen

Hi David
Saw your posts regarding your Tomcat/Servlet troubles.
What version of Tomcat are you using ? this makes a diff., especially concerning the problems you describe.
I can recommend the www.coreservlets.com site. Has exellent info on basic Tomcat/Servlet/JSP configuration for major Tomcat versions.
And hey - let people know of you progress - preferably in this thread.
Martin
16 years ago
Hi all
Using Eclipse 2.0.1 could anyone explain the difference between importing a JAR and adding the same JAR to the Java Build Path. Is both actions necessary ? is this dependent on settings in Eclipse ? perhaps source location or ? I cannot figure out the relationship between the two.
Regards,
Martin
Thanks for your response.
This might be a silly question, but what is the import into Eclipse good for, if I need to add the jar to the build path ? I seem to remember to be able to use jars just by importing them into a project. Is this servlet specific ? or is it an Eclipse 2.0.1 thing ?
Martin
Thanks for the the answer. The J2SDK was installed before Eclipse and I can compile and run "normal" java programs without any problems, also programs that require that I import jars.
I actually tried just importing the servlet jar but it doesn't change anything. HttpServlet is redlined in the class definition, but not in the import statements, which to me is really strange.
My setup in in eclipse is as follows:
A project called test. Into the test project I import servlet.jar. A source file called HelloServlet.java with the following contents:

This should be really simple, but I can't figure out what is wrong.
Any help is as always greatly appreciated.
Martin
Hi there.
How do I compile/run/debug servlets using Eclipse 2.0.1. What do I need to import/setup ? does J2SDKEE need to be installed before I install Eclipse ? a step by step guide from standard Eclipse installation to compiled/run basic servlet would be great, but of course any help would be greatly appreciated.
Cheers,
Martin
Hi Kevin
"Object-Oriented Programming with Java: An Introduction" ISBN: 0-13-086900-7 is a great book to learn from, although very textbook like.
Combine it with Java Cookbook Solutions and Examples for Java Developers, ISBN: 0-596-00170-3,
and you have a winning combination - IMHO.
Regards,
Martin
17 years ago
Just downloaded the Tomcat 4.0.4 bin - installs like a charm on my XP Pro box - beautiful job by the Apache people.
One strange thing though:
I a quite a newbie to Java/Servlets/JSP but I hope I am right on this one.
Does the code and the compiled version of the servlet example "Request Header Example" match ?
The code(appears if you push the screwdriver in the upper right hand corner) seems to produced a quite crude text output while running the compiled example produces a html table with a gray background behind the header names.
Cheers,
Martin
17 years ago

Originally posted by Griff James:
Thanks Martin, I thought no-one would reply!
I'll try these out when I get home tonight.
For now it's back to the Lloyds Law Reports and the joy of Maritime Law, until maybe, just maybe, I can escape to a shiny new career in IT!!


One more thing. If I was you I would consider uninstalling the Java 1.3 and Forte and download and install Java 1.4 SDK instead.
I started out using Forte but quickly reverted to a texteditor(Textpad) and a comandline. Forte hides too many details, details you will need to know sooner or later. I know a commandline looks dull and so do programs that produce text output only but starting with these tools makes it easiere to see the big picture later - or at least that is my experience.
Regards,
Martin
17 years ago
Hi Griff
Sounds like a classpath problem to me. As far as I know Forte uses it's own classpath. You have to make sure that the classpath is set for in your environment - in your case windows. Try taking a look at :
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html#2b
and
http://java.sun.com/docs/books/tutorial/uiswing/start/_envVariables.html
regards,
Martin
17 years ago
That the absolute speeds should differ I get, but the relative too ? the array should be the fastest in both access and allocation shouldn't it ?
Or is it just me being a silly newbie ?
Martin
18 years ago
Ad 1) Thank you very much Cindy - silly of me not to notice.
Ad 2) Does anyone have an answer for that one ?

Originally posted by Cindy Glass:
Martin,
It is not important that the public static variables be declared at the end of your class instead of at the beginning. what IS important is that they are declared OUTSIDE of the main method.
If you look where they are at the end, the are placed after the main method closed. Where they are at the top is inside the main method. That makes the variables local to the main method and they cannot be public static (however they could be final).
Local variables belong to the method or block that they are declared in, not the instance and not the class (static).
If you move the statements BEFORE the main declaration it will work.


18 years ago
Ad 1) I think I get this one, although I cannot figure out why it is important that the:
public static final int MAXSIZE = 100000;
public static final int NTRIES = 10;
is at the end of the class, as opposed to at the begining like this:
import java.util.*;
class VectorBenchmark
{ public static void main(String[] args)

public static final int MAXSIZE = 100000;
public static final int NTRIES = 10;

{ Vector v = new Vector();

long start = new Date().getTime();
for (int i = 0; i < MAXSIZE; i++)
v.add(new Integer(i));
....
Ad 2) I realise that the values will vary, but how come they are not proportional, e.g. vector allocation is faster than array allocation, while vector access is slower than array access ?

Originally posted by Val Dra:
1) Local declaration of variables do not use keywords such as private , public,static or protected.SO if you left them in your main method you would have to take these keywords out.
2) this depends a lot on a hardware ,the faster the cpu better results.


18 years ago
Hi All
Two questions that will undoubtedly reveal me as a complete newbie.
I have keyed in Example 5-3 from "Core Java 2 Vol. 1 - Fundamentals".

My questions are these:
1) Why doesn't the code compile if i move the following code:
public static final int MAXSIZE = 100000;
public static final int NTRIES = 10;
to the top, as indicated by the commented out section ?(of course it compiles with comments, but not without).
2) I get the following results from running the program:
Allocating vector elements: 180 miliseconds
Allocating array elements: 211 miliseconds
Accessing vector elements: 1412 miliseconds
Accessing array elements: 1031 miliseconds
These results are not proportional to those found in the text - why ?
Thank you in advance for your answers.
Martin C.
(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited May 30, 2001).]
18 years ago
Hi all
I am new to both Java and XML. Have found XML to be a though subject to start with, but also very interesting.
Does anyone know of a sample XML application, preferably containg a simple SWING GUI, as I am also trying to figure that part of Java out ? if the application does some kind of search an retrival from one or more xml files that would be great.
Thanks in advance.
Martin