?
Solved

Newbie Questions: so be gentle..

Posted on 2004-11-17
8
Medium Priority
?
401 Views
Last Modified: 2013-11-24
OK, I am a newbie to Java and have absolutely no idea what I am doing, so I am going to ask some stupid questions.

I understand the syntax and all that, but I am having trouble with the basic stuff like the app server and all that.
Here goes:

I have ColdFusion installed, which runs on JRun4, then I also have Sun j2eesdk-1_4_01 installed.

1: Can I get rid of one app server and just run everything on JRun4?
2. Is one better than the other?
3. I am trying to compile a class, but keep running into errors, I know why I get the errors, I get the errors because the class I am trying to compile cannot find the classes I need to import.
   3.a. Where in gods name do I put my classes so it can find all the import classes?
   3.b. I am guessing somewhere under one of the app servers, but which one and where?

The class looks like the following:

package jrun.support;

import javax.servlet.*;
import javax.servlet.http.*;

public class JRunHttpSessionListener implements HttpSessionListener
{
    public void sessionDestroyed( HttpSessionEvent session )
    {
        HttpSession objSession = session.getSession();
        System.out.println(" (objSession) Destroyed:ID=" + objSession.getId());
    }
}

I have a ton load of other questions, but I'll start with the above.
PS. I am trying to perform an action upon timeout of a session variable.
0
Comment
Question by:Tacobell777
8 Comments
 
LVL 3

Expert Comment

by:vikraman_b
ID: 12610670
Hi
can u post ur errors
0
 
LVL 3

Expert Comment

by:vikraman_b
ID: 12610697
check this..
for installating,deployment and configuration....


http://www.macromedia.com/support/coldfusion/j2ee/phase2-jrun4-deploy.html
0
 
LVL 17

Author Comment

by:Tacobell777
ID: 12610720
Following are the errors, just a FYI there are 5 questions in my post and a link to install or deploy just won't do..

C:\Sun\AppServer\jdk\bin>javac e:\temp\JRunHttpSessionListener.java -classpath C
:\Sun\AppServer\docs\api
error: cannot read: e:\temp\JRunHttpSessionListener.java
1 error

C:\Sun\AppServer\jdk\bin>javac C:\JRun4\servers\default\default-ear\default-war\
WEB-INF\classes\JRunHttpSessionListener.java
C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes\JRunHttpSession
Listener.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes\JRunHttpSession
Listener.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes\JRunHttpSession
Listener.java:6: cannot resolve symbol
symbol  : class HttpSessionListener
location: class jrun.support.JRunHttpSessionListener
public class JRunHttpSessionListener implements HttpSessionListener
                                                ^
C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes\JRunHttpSession
Listener.java:8: cannot resolve symbol
symbol  : class HttpSessionEvent
location: class jrun.support.JRunHttpSessionListener
    public void sessionDestroyed( HttpSessionEvent session )
                                  ^
C:\JRun4\servers\default\default-ear\default-war\WEB-INF\classes\JRunHttpSession
Listener.java:10: cannot resolve symbol
symbol  : class HttpSession
location: class jrun.support.JRunHttpSessionListener
        HttpSession objSession = session.getSession();
        ^
5 errors
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
vikraman_b earned 1000 total points
ID: 12611343
Hi Tacobell777 ,

The best way to avoid these errors is ..
The following instruction will make to create the war file and it also avoid all servlet/jsp related compile errors also u can add exteral jars too..to automatically set the classpath.
pls follow....

http://www-106.ibm.com/developerworks/opensource/library/os-ectom/

then after choosing the tomcat project ..now write click to create a new class..e.g
JRunHttpSessionListener (ur code)
 if u want to add external jars ..just right click on ur project the click the propties then select the javabuild path (left frame) then select the libraries tab the click the add external jars button ..browse to get the jar then click OK.

After finish coding -->click project menu-->and select the Rebuild All.

It will compile successfully and put all the classes in under WEB-INF/classes directory.

if u want to create a war of this project just right click on the project and select TOmcat project the select the Export the WAR file sets in project properties..

u can the specify the path where u need to put ur war file..
right click ur project  select properties then select the tomcat node and select the Export to War settings tab..there u can browse to select ...

Hope this will help to solve all ur compilation issues ..It will be the best way to do..without any help also it will point out the errors and it will give the possible solutions..A Good IDE

All the best
ANy doubts u ask me..



0
 
LVL 2

Assisted Solution

by:tomgallo
tomgallo earned 1000 total points
ID: 12612020
Taco,

I agree with vikraman_b. Eclipse is the best IDE for Java/Tomcat use that I ever tried.
However focusing in your questions, more especifically the third:
You have to create an enviromental variable that is CLASSPATH, in this variable we put all the paths to our classes to compile ours .java and do the imports correctly.
If you want, you can use packages. These are subdirs that have classes in it or more subdirs with classes. To use packages you have also to put the paths in the CLASSPATH.

Hope this solve the compilation errors.
-tom

PS: give Eclipse a try... I love it!
0
 
LVL 2

Expert Comment

by:tomgallo
ID: 12612033
Taco,
Another comment... do not worry at all... app servers are not the basic stuff... they are a pain in the a.. hard to configure at the beginning, and also hard to understand.
One piece of advice, be patient, read a lot and try everything!!!

Welcome to Java, hope you enjoy!
-tom

0
 
LVL 3

Expert Comment

by:lilian-arnaud
ID: 12619927
Try ant (http://ant.apache.org/) to compile your java files and deploy your webappli in your app server.

Ant and its build.xml file replace the command "make" and his makefile for java ...
0
 
LVL 3

Expert Comment

by:drjustin
ID: 12626346
Since you are a newbie, app server is just not the thing you want to look at.
Here are some instructions on how to do J2EE in a lightweight way - but still with all the power of real enterprise app.

If you don't know about Spring (www.springframework.org) now is the time to look at it. It covers all things that you are looking for - easy db integration, transaction handling, UI, configuration, documentation, forums, ... It has steep lurning curve, but all this stuff mentioned really helps and once you master it, there's no limit to what you can do :-).

All things below are already integrated with Spring:

- db integration (db independent - only jdbc driver limitations):
  - simple sql mapping: iBatis (www.ibatis.com)
  - more advanced ORM tool: Hibernate (www.hibernate.org)

- user interface:
  - most widely spread: Struts (struts.apache.org/)
  - easy usage: WebWork (www.opensymphony.com/webwork)
  - component oriented: Tapestry (jakarta.apache.org/tapestry)
  - integrated: Spring MVC (www.springframework.org/docs/reference/mvc.html)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question