Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of package statement

 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not seen this documented anywhere, but in hopes of saving some other newbie a week of pounding on the desk and searching the forums and books until the wee hours, take a look at the following:
If you place package packageName; in your java file and compile from the console, you will need to type cd.. at least once and use "java lowerFolder.javaFile" before running in order to keep from getting this error:

else do not enter package packageName in your java file. I discovered this by much trial and error :roll:
doco all happy now
Much thanks to Yehor for helping me see the light.](response to question)
[ February 25, 2003: Message edited by: doco mastadon
[ February 25, 2003: Message edited by: doco mastadon ]
 
aliasger talib
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi doco,
Actually, the _only_ way you can compile a Java file with a package structure is from the root folder with the package structure in the compile statment at the command prompt.
There's no other way.
:-)
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I know that now. But if you compile from the console then try running the compiled java file from the same directory as java file is resident in, you will receive the error message displayed in my post. That is, unless you do not have a package statement in your compiled file then, you can run from the same directory.
A simple statement such as the one you just made would be most helpful in documentation of how to setup and USE Java. A subtle fact missing from ANY and ALL documentation that I have seen.
doco
[ February 26, 2003: Message edited by: doco mastadon ]
 
Marilyn de Queiroz
Sheriff
Posts: 9067
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aliz,

Why did you change your display name to one that violates the JavaRanch Naming Policy?

Please change it back, or at least to a name that conforms. Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic