User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 397,816 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,622 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 627 | Replies: 4
Reply
Join Date: Feb 2007
Posts: 2
Reputation: Pauer100 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pauer100 Pauer100 is offline Offline
Newbie Poster

Help Problem using serializable coding

  #1  
Feb 8th, 2007
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, 4 views)
File Type: java EmployeeAdd.java (1.1 KB, 4 views)
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2005
Posts: 72
Reputation: Cudmore is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 5
Cudmore's Avatar
Cudmore Cudmore is offline Offline
Junior Poster in Training

Re: Problem using serializable coding

  #2  
Feb 8th, 2007
import java.io.*;
import java.util.*;
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.
synchronized (theWorld) { System.out.println ("It's all mine..."); }
How many people have code in their Sigs?
Reply With Quote  
Join Date: Feb 2006
Posts: 1,363
Reputation: masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough 
Rep Power: 8
Solved Threads: 117
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: Problem using serializable coding

  #3  
Feb 8th, 2007
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.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Feb 2006
Posts: 1,363
Reputation: masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough masijade is a jewel in the rough 
Rep Power: 8
Solved Threads: 117
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: Problem using serializable coding

  #4  
Feb 8th, 2007
Originally Posted by Cudmore View Post
import java.io.*;
import java.util.*;
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.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Join Date: Feb 2007
Posts: 2
Reputation: Pauer100 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Pauer100 Pauer100 is offline Offline
Newbie Poster

Re: Problem using serializable coding

  #5  
Feb 8th, 2007
Thanks very much for helping me out with that query.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Java Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 6:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC