Solved

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

Posted on 2002-04-21
7
244 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
[X]
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
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Should localization be done inside spring controller 5 37
JAVA API design with micro service cloud in mind 1 82
Problem to Alipay 10 72
jsp error 6 48
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

730 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