Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2006

Tip: Looking for answers? Try searching our database.

I can't compile this - why?

Thread view: 
phillip.s.powell@gmail.com - 05 Feb 2006 19:32 GMT
I do not possess any means of compiling any .java file that imports
javax.* or anything J2SE-related, thus, I have to compile it remotely
on a remote host (www.myjavaserver.com), however, for some reason this
file will not compile but will not produce any errors, warnings, or any
display of any kind - but no .class file is ever found.

import java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*;

/**
* Borrowed from http://forum.java.sun.com/thread.jspa?threadID=703076
*
* @access public
* @author Phil Powell
*/
public class RequestParameterResetter extends HttpServletRequestWrapper
{

   private HttpservletRequest origRequest;
   private Map<String, String> parameterMap;

   public RequestParameterResetter(HttpServletRequest request) {
       super(request);
       origRequest = request;
       parameterMap = new HashMap<String,String>();
   }

   public String setParameter(String key, String value) {
       String oldValue = parameterMap.put(key,value);
       if (oldValue == null) oldValue = origRequest.getParameter(key);
       return oldValue;
   }

   public String getParameter(String key) {
       String value = parameterMap.get(key);
       if (value == null) value = origRequest.getParameter(key);
       return value;
   }
}

Could someone tell me what I'm missing in order for this to properly
compile?

Thanx
Phil
zero - 05 Feb 2006 20:35 GMT
> import java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*;

import statements, like all other statements, must end withe a semicolon.  
They cannot be cascaded together.  Try this instead:

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
IchBin - 05 Feb 2006 20:37 GMT
> I do not possess any means of compiling any .java file that imports
> javax.* or anything J2SE-related, thus, I have to compile it remotely
[quoted text clipped - 12 lines]
> public class RequestParameterResetter extends HttpServletRequestWrapper
> {

Try using HttpServletRequest and not HttpservletRequest!

>     private HttpservletRequest origRequest;
>     private Map<String, String> parameterMap;

[snip code]

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

IchBin - 05 Feb 2006 20:39 GMT
>> I do not possess any means of compiling any .java file that imports
>> javax.* or anything J2SE-related, thus, I have to compile it remotely
[quoted text clipped - 19 lines]
>>
> [snip code]

Also do what zero suggested and you will be ok..

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

phillip.s.powell@gmail.com - 06 Feb 2006 05:30 GMT
I did just that, and it still didn't compile.  My other classes I wrote
compiled just fine even with the import statement strung together into
a single line

Phil

> >> I do not possess any means of compiling any .java file that imports
> >> javax.* or anything J2SE-related, thus, I have to compile it remotely
[quoted text clipped - 31 lines]
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor,  Regular Guy (1952-)
phillip.s.powell@gmail.com - 06 Feb 2006 05:32 GMT
Thanx I noticed that.. still won't compile even with changes.

Cannot download Eclipse, my home PC is ancient and cannot handle the
memory hogging (that and the online tutorial was too foreign for me to
understand)

Phil

> > I do not possess any means of compiling any .java file that imports
> > javax.* or anything J2SE-related, thus, I have to compile it remotely
[quoted text clipped - 29 lines]
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor,  Regular Guy (1952-)
Roedy Green - 06 Feb 2006 00:26 GMT
On 5 Feb 2006 11:32:19 -0800, "phillip.s.powell@gmail.com"
<phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>import java.io.*, java.util.*, javax.servlet.*, javax.servlet.http.*;

Even if that is legal that makes it harder for someone reading the
code to figure out what it does.  Do one class per line, without *s.

Eclipse will convert that for you with "organise imports"
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 06 Feb 2006 00:27 GMT
On 5 Feb 2006 11:32:19 -0800, "phillip.s.powell@gmail.com"
<phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>Could someone tell me what I'm missing in order for this to properly
>compile?

It is missing a package.  Normally only toy programs have no package.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

phillip.s.powell@gmail.com - 06 Feb 2006 05:33 GMT
Define "toy program" for me, please, have no clue what you're talking
about within context, other than the real thing.

Phil

> On 5 Feb 2006 11:32:19 -0800, "phillip.s.powell@gmail.com"
> <phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
[quoted text clipped - 7 lines]
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
IchBin - 06 Feb 2006 08:19 GMT
> Define "toy program" for me, please, have no clue what you're talking
> about within context, other than the real thing.
[quoted text clipped - 11 lines]
>> Canadian Mind Products, Roedy Green.
>> http://mindprod.com Java custom programming, consulting and coaching.

I have never tried to compile at the website you mentioned. Looks like
you should be able to compile at www.myjavaserver.com they have the
following support which includes the ones you need:

Java services,
J2SE 5.0 based application server,
Servlet 2.3,
Java Server Pages (JSP) 1.2
Pre-installed third-party libraries.

*What is the exact error you are getting? This complies for me*

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class RequestParameterResetter extends HttpServletRequestWrapper
 {
     private HttpServletRequest origRequest;
     private Map<String, String> parameterMap;

     public RequestParameterResetter(HttpServletRequest request)
     {
         super(request);
         origRequest = request;
         parameterMap = new HashMap<String,String>();
     }
     public String setParameter(String key, String value)
     {
         String oldValue = parameterMap.put(key,value);
         if (oldValue == null) oldValue = origRequest.getParameter(key);
         return oldValue;
     }
     public String getParameter(String key)
     {
         String value = parameterMap.get(key);
         if (value == null) value = origRequest.getParameter(key);
         return value;
     }
 }

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

phillip.s.powell@gmail.com - 06 Feb 2006 08:38 GMT
I am getting no error, and deduced that the problem is in
myjavaserver.com as it gives a blank page when you try to compile even
made-up .java files, much less working or non-working ones!

Phil

> > Define "toy program" for me, please, have no clue what you're talking
> > about within context, other than the real thing.
[quoted text clipped - 73 lines]
> 'If there is one, Knowledge is the "Fountain of Youth"'
> -William E. Taylor,  Regular Guy (1952-)
Roedy Green - 06 Feb 2006 09:12 GMT
On 5 Feb 2006 21:33:14 -0800, "phillip.s.powell@gmail.com"
<phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>Define "toy program" for me, please, have no clue what you're talking
>about within context, other than the real thing.

A student assignment, a one shot program, an experiment to find out
how Java works, a program snippet.

Any program used in a company, any program you distribute for
production should have a package.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

phillip.s.powell@gmail.com - 06 Feb 2006 19:18 GMT
How about a chatroom you build for your metalhead friends for free?

Phil

> On 5 Feb 2006 21:33:14 -0800, "phillip.s.powell@gmail.com"
> <phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
[quoted text clipped - 11 lines]
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 06 Feb 2006 23:12 GMT
On 6 Feb 2006 11:18:45 -0800, "phillip.s.powell@gmail.com"
<phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>How about a chatroom you build for your metalhead friends for free?

I presume that is an insult of some kind, but sorry, it went over my
head. What is a "metalhead" and what have chatrooms to do with whether
production classes should have packages?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

phillip.s.powell@gmail.com - 07 Feb 2006 02:51 GMT
That is amazing.  Apparently different cultures, different worlds,
different languages play into this.

As it is often done in newsgroups, so shall I do likewise:
http://en.wikipedia.org/wiki/Metalhead

This will clue you in.. and I'm building a chatroom so that we can chat
with each other because we like doing that.  No work specs, no
requirement docs, no nothing, just for the sake of having it happen.

Phil

> On 6 Feb 2006 11:18:45 -0800, "phillip.s.powell@gmail.com"
> <phillip.s.powell@gmail.com> wrote, quoted or indirectly quoted
[quoted text clipped - 8 lines]
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Java custom programming, consulting and coaching.
Noodles Jefferson - 06 Feb 2006 07:42 GMT
In article <1139167938.987569.254420@g44g2000cwa.googlegroups.com>,
phillip.s.powell@gmail.com took the hamburger, threw it on the grill,
and I said "Oh wow"...

> I do not possess any means of compiling any .java file that imports
> javax.* or anything J2SE-related, thus, I have to compile it remotely
[quoted text clipped - 37 lines]
> Could someone tell me what I'm missing in order for this to properly
> compile?

You need the Enterprise Edition. Javax isn't part of the standard SDK.
You can use it when you use Tomcat because Tomcat provides those classes
for you.

Signature

Noodles Jefferson
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jellyroll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum,
a pocketknife, and a smile."

-- Robert Redford "Spy Game"

Roedy Green - 06 Feb 2006 09:14 GMT
On Mon, 6 Feb 2006 01:42:11 -0600, Noodles Jefferson
<silverbells@tacoshells.com> wrote, quoted or indirectly quoted
someone who said :

> Javax isn't part of the standard SDK.

javax.swing is but javax.servlet is not.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Noodles Jefferson - 07 Feb 2006 04:26 GMT
> On Mon, 6 Feb 2006 01:42:11 -0600, Noodles Jefferson
> <silverbells@tacoshells.com> wrote, quoted or indirectly quoted
[quoted text clipped - 3 lines]
>
> javax.swing is but javax.servlet is not.

I forgot about Swing. Still, it's kind of weird how some classes of the
package are in the standard SDK and some aren't. They're not usually
like that, are they?

Signature

Noodles Jefferson
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jellyroll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum,
a pocketknife, and a smile."

-- Robert Redford "Spy Game"

phillip.s.powell@gmail.com - 07 Feb 2006 16:36 GMT
Incidentally, I got it to compile at home and it was a LOT easier than
I thought.. just add the path to servlet.jar to CLASSPATH and reboot
and you can compile anything using javax.servlet or javax.servlet.*

Phil

> > On Mon, 6 Feb 2006 01:42:11 -0600, Noodles Jefferson
> > <silverbells@tacoshells.com> wrote, quoted or indirectly quoted
[quoted text clipped - 20 lines]
>
> -- Robert Redford "Spy Game"
Monique Y. Mudama - 07 Feb 2006 17:45 GMT
>> On Mon, 6 Feb 2006 01:42:11 -0600, Noodles Jefferson
>> <silverbells@tacoshells.com> wrote, quoted or indirectly quoted
[quoted text clipped - 7 lines]
> the package are in the standard SDK and some aren't. They're not
> usually like that, are they?

Actually, javax.swing and javax.servlet are two diffrent packages ...

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Noodles Jefferson - 07 Feb 2006 21:35 GMT
> >> On Mon, 6 Feb 2006 01:42:11 -0600, Noodles Jefferson
> >> <silverbells@tacoshells.com> wrote, quoted or indirectly quoted
[quoted text clipped - 9 lines]
>
> Actually, javax.swing and javax.servlet are two diffrent packages ...

Ah. Then there you go. Thanks Monique.

Signature

Noodles Jefferson
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jellyroll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum,
a pocketknife, and a smile."

-- Robert Redford "Spy Game"

Rasto - 06 Mar 2006 15:24 GMT
I have the same problem with myjavaserver.com - this problem with
compiling still exists!!!
I wrote them, but I haven't become no answer yet...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.