Solved

a question about jdk1.4~~~help~~~

Posted on 2002-04-21
7
211 Views
Last Modified: 2010-03-30
i have a servlet and a CheckUser class. the CheckUser class and the servlet in different path.
so if the servlet want to use CheckUser class must import it..if commented out "import CheckUser;",
the compiler will say "can't find class CheckUser".

but in the CheckUser class, we did not use something like "package com.***.***"....we just put CheckUser
class in a path which is exist in the CLASSPATH...

in jdk 1.3 no problem. but the problem appears in jdk1.4..a error report: says '.' expected

as CEHJ said: Java classes are *always* in packages, even if there is no 'package' declaration...
so, i want to know which package CheckUser belongs to? because i didnot use 'package' declaration.....(if
CheckUser.java in path /home/com/***/ and /home/com/*** in the CLASSPATH)
0
Comment
Question by:wh111
7 Comments
 
LVL 16

Expert Comment

by:heyhey_
Comment Utility
post the full javac error message
0
 
LVL 35

Expert Comment

by:girionis
Comment Utility
 And post your servlet code as well...
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
Comment Utility
The way to avoid the compiler error is to compile thus:
javac -sourcepath <path to CheckUser> <filename>.java
There is no need then to import CheckUser at all.

What I would say though, is that one ought to minimise source file dispersal. Think about the comment you made about packages. If there are the correct relations between packages, there is no need to yank together dispersed source.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:nebeker
Comment Utility
Java 1.4 is a lot more strict about import statements...
0
 
LVL 9

Expert Comment

by:Ovi
Comment Utility
Normally if you are sure that your file is in the classparh, never will be necesary to import'it.
0
 
LVL 9

Expert Comment

by:Venci75
Comment Utility
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Answered by: CEHJ
Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venci75
EE Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
Comment Utility
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now