• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unresolved Compilation Problem  RSS feed

 
Neyla Adam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
My network flow problem doesn't seem to work because of an unresolved compilation problem.


this is the code:



 
Tim Cooke
Marshal
Posts: 3873
233
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Neyla, welcome to the Ranch!

You forgot to tell us what the compilation error you're seeing is?
 
Mike London
Ranch Hand
Posts: 1476
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I copied your code right in to Intellij and it compiles fine and even runs (waits for input).

What error are you getting?
 
Neyla Adam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.Error: Unresolved compilation problem:

at aww.Main5.main(Main5.java:67)

that's the error i get in eclipse..
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does  the class belong to any package named aww?  If so it should be under the package called aww, and we don't see any package statement in your code.
 
Mike London
Ranch Hand
Posts: 1476
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik Dey wrote:Does  the class belong to any package named aww?  If so it should be under the package called aww, and we don't see any package statement in your code.


That's really strange. I copied and pasted the code right into Intelli and it had no issues and even ran.

Try the community (free) edition of Intellij as a test.

I don't think it's your code.

And, I did zero configuration chores.

-- mike
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just took one of my other code (managed by eclipse), and removed the package statement, but still kept it in the package. Eclipse will complain about something like "declared package AAA does not match BBB blah blah blah".

Additionally, ran that broken code (even though it has an error)... eclipse will complain, and popup to confirm.. and forced eclipse to run anyway. The resultant error message at console was "unresolved compilation problem: at xxx.yyy.main(zzz.java)".... just like as mentioned by the OP.

So, it is two problems. One, eclipse is configured to expect the class in the package, but with the code, the class is not in the package. And two, the error message is ignored; the application is forced to run, forcing eclipse to print out a nonsensical message, because that information is lost at run time.


Now, is the missing package the underlying cause? or did the OP simply didn't cut and paste it? ... This is not clear. There is no visibility into that. The OP need to tell us what the compilation errors are, and not just tell us the errors when forcing the application to run.

Henry
 
Mike London
Ranch Hand
Posts: 1476
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
.
.
.
The OP need to tell us what the compilation errors are, and not just tell us the errors when forcing the application to run.
Henry


Yep, agreed.
 
Neyla Adam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now the compilation problem is solved: i had to declare the package..
now I get those errors though:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at aww.Main5.augmentingPathExists(Main5.java:24)
at aww.Main5.computeMaximumFlow(Main5.java:50)
at aww.Main5.main(Main5.java:120)

and I do not understand why.. does anyone get it?
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neyla Adam wrote:now the compilation problem is solved: i had to declare the package..
now I get those errors though ... and I do not understand why.. does anyone get it?


The stacktrace gives you tons of information...

Neyla Adam wrote:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at aww.Main5.augmentingPathExists(Main5.java:24)
at aww.Main5.computeMaximumFlow(Main5.java:50)
at aww.Main5.main(Main5.java:120)


Basically, your main() method called the computeMaximumFlow() method, which called the augmentingPathExists() method. And somewhere in the augmentingPathExits() method, around line 24 of the Main5.java file, you encountered the error.

The error is an ArrayIndexOutOfBounds exception, which is what is thrown when trying to dereference an array. Additionally, you are trying to get element zero, which is the first element of the array. And it failed, which means that the array doesn't have a first element.

Following this, it is likely your "visited" array, which you probably instantiated to hold zero elements. Put a debugging message, either at the instantiation of the array, or before accessing the array, to confirm the size... and you will see the issue.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!