Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2002-04-21
7
237 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_
ID: 6957504
post the full javac error message
0
 
LVL 35

Expert Comment

by:girionis
ID: 6957583
 And post your servlet code as well...
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 6957645
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

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

Expert Comment

by:Ovi
ID: 6962168
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
ID: 7973096
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
ID: 8021383
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 37
Which non-HTML GUI front end to use with Java? 3 24
how to debug htl and js pages 8 38
Html Table Looping (part 2) 5 27
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

789 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