dcsimg
Why Jbuilder8 can't compile java code without "package" statement
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   harv_shen
Posted On:   Sunday, March 2, 2003 05:45 PM

I have a project that consists of two java files: ==first.java== class first { public final static String CHANNEL="WEB"; //code here } ==second.java== import first; class second{ System.out.println(first.CHANNEL); //other codes } ========== When I try to make this project, jbuilder just complains that "second.java": Error #: 200 : '.' expected at line 1, column 16 I have no problem compile this project in Jbuilder 4,5,6 and 7. But jbuilder8 can't, is there any setting I can do with this? Thank you very much!    More>>

I have a project that consists of two java files:

			
==first.java==
class first {
public final static String CHANNEL="WEB";
//code here
}

==second.java==
import first;
class second{
System.out.println(first.CHANNEL);
//other codes
}
==========

When I try to make this project, jbuilder just complains that
"second.java": Error #: 200 : '.' expected at line 1, column 16

I have no problem compile this project in Jbuilder 4,5,6 and 7. But jbuilder8 can't, is there any setting I can do with this? Thank you very much!    <<Less

Re: Why Jbuilder8 can't compile java code without "package" statement

Posted By:   Rod_Macpherson  
Posted On:   Thursday, March 27, 2003 06:06 AM

You cannot "fail to provide" a package statement since you get an implicit package statement (the default package) if you omit your own. You can compile classes without package statements all day without error.


The problem is "import" statements do not assume the default package:


import first;


This is potentially ambiguous: delete it. You do not need to import classes within the same package and you cannot import classes that are in the default package.


p.s. packages should start with an uppercase letter in the off chance you are not doing that in your actual class names.

Re: Why Jbuilder8 can't compile java code without "package" statement

Posted By:   Alex_Pakka  
Posted On:   Thursday, March 13, 2003 12:12 PM

You can't. And it is probably good so.

Simply put, it is a violation of Java Language Specification. I had to recompile couple of my .dll's for JNI in order to be compliant myself.


http://community.borland.com/article/0,1410,29710,00.html
About | Sitemap | Contact