943,670 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1068
  • Java RSS
Feb 8th, 2007
0

Problem using serializable coding

Expand Post »
I have an employee class see atthachement whic compiles fine and i have written some code called EmployeeAdd which uses the Employee Class which was deifining an Employee.

However my problem is when i am trying to import the Employee in to EmployeeAdd the error message i am getting is the following

error expected . at end of the line after import EmployeeAdd.java it just does not compile for some reason

This code was working fine before i am using jdk version 2.0

If anyone can help me plz

Thanks

Richard
Attached Files
File Type: java Employee.java (1.5 KB, 10 views)
File Type: java EmployeeAdd.java (1.1 KB, 9 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pauer100 is offline Offline
2 posts
since Feb 2007
Feb 8th, 2007
0

Re: Problem using serializable coding

Java Syntax (Toggle Plain Text)
  1. import java.io.*;
  2. import java.util.*;
  3. import Employee;

The problem is with import Employee; --- you can't import classes from the same package without at least giving the package name/whatever.

Just remove import Employee; and you should be fine. As long as the classes are in the same directory/package, they're automatically available to one another.
Reputation Points: 20
Solved Threads: 6
Junior Poster in Training
Cudmore is offline Offline
74 posts
since Nov 2005
Feb 8th, 2007
0

Re: Problem using serializable coding

It is frowned upon to place classes in the "main" or "default" or "unnamed" package. And this is one of the problems that arise from that. Place each of these classes into a package, then import package.Employee and everything will be okay. Also, if they are in the same package, you don't need the import statement, at all.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Feb 8th, 2007
0

Re: Problem using serializable coding

Click to Expand / Collapse  Quote originally posted by Cudmore ...
Java Syntax (Toggle Plain Text)
  1. import java.io.*;
  2. import java.util.*;
  3. import Employee;

The problem is with import Employee; --- you can't import classes from the same package without at least giving the package name/whatever.

Just remove import Employee; and you should be fine. As long as the classes are in the same directory/package, they're automatically available to one another.
Part of the problem, is tht they are not in a package at all.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Feb 8th, 2007
0

Re: Problem using serializable coding

Thanks very much for helping me out with that query.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Pauer100 is offline Offline
2 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: how to tokenize a long string by using another string
Next Thread in Java Forum Timeline: Exception





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC