declared package does not match the expected package

1,322 views
Skip to first unread message

Eric Stob

unread,
Jul 9, 2013, 4:50:33 AM7/9/13
to scala-i...@googlegroups.com
Using Kepler
Eclipse Standard/SDK 2.0.0.20130613-0530 epp.package.standard null
Scala IDE for Eclipse 4.0.0.nightly-2_10-201307050323-ea757cf org.scala-ide.sdt.feature.feature.group scala-ide.org

I am getting
Description Resource Path Location Type
The declared package "com.sdl.si.api" does not match the expected package "com.sdl.si.api" Config.java /api/src/main/java/com.sdl.si.api line 1 Java Problem

the project was created using sbteclipse.
the project builds just fine in sbt.

the error message itself is very strange.  com.sdl.si.api most certainly does match com.sdl.si.api.

I appreciate your help.

Luc Bourlier

unread,
Jul 9, 2013, 5:29:28 AM7/9/13
to scala-i...@googlegroups.com
Awesome!!

err, sorry.

What it means when it says that "com.sdl.si.api" doesn't match "com.sdl.si.api", is that the folder structure src/main/java/com.sdl.si.api doesn't match the package declaration "com.sdl.si.api'. What it wants is a folder structure where each section of package (separated by '.') is it own folder: src/main/java/com/sdl/si/api.

There is nothing we can do, it is a requirement from Java.

The weird part is the fact that sbt doesn't return an error. I have some idea why, I'll push the info to the sbt project.

HTH,
Luc

David Bernard

unread,
Jul 9, 2013, 6:44:15 AM7/9/13
to scala-i...@googlegroups.com
Hi,

It's an eclipse requirement (not a java) for source layout.
I'm no longer use dot in package, because it's a pain when you navigate in source outside of ide (file manager, github,...). I use '_' => flat layout like with '.' in IDE.

my 2c.


--
You received this message because you are subscribed to the Google Groups "Scala IDE User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-ide-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Luc Bourlier

unread,
Jul 9, 2013, 8:09:05 AM7/9/13
to scala-i...@googlegroups.com

Le mardi 9 juillet 2013 12:44:15 UTC+2, David Bernard a écrit :
Hi,

It's an eclipse requirement (not a java) for source layout.
I'm no longer use dot in package, because it's a pain when you navigate in source outside of ide (file manager, github,...). I use '_' => flat layout like with '.' in IDE.

my 2c.


Yes, I was looking at this, and the requirement is only for class files:

"You should arrange source files in a directory tree that  reflects  their
package  tree.  For  example,  if  you  keep  all  your  source  files in
/workspace, the source code for com.mysoft.mypack.MyClass  should  be  in
/workspace/com/mysoft/mypack/MyClass.java." -- man javac

The key word is 'should'.

I have been using Java for -way too many- years, and I don't think I ever knew this one.
I guess my misconception comes from the fact that javac (with the default options) would not put the class files in the correct folder structure if the source folder is not right:

"By  default,  the  compiler puts each class file in the same directory as
its source file. ..." - man javac

Knowing this, the limitation in Eclipse is really ugly ...

Luc

Donny Nadolny

unread,
Jul 9, 2013, 8:31:30 AM7/9/13
to scala-i...@googlegroups.com
It makes a bit more sense when you know that, although javac will happily put the .class file in the same directory as the source, when it comes time to run it the JVM will only look for a class in the expected folder. If Eclipse allowed you to put your source in whatever folder you wanted, then it would be hard to use another compiler because you'd have to move the .class files around.


--

Eric Stob

unread,
Jul 9, 2013, 10:15:24 PM7/9/13
to scala-i...@googlegroups.com
Thank you everyone for your feedback.  I will try to reorganize my file structure to please eclipse.
Reply all
Reply to author
Forward
0 new messages