• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Unresolved Compilation Problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:



 
Marshal
Posts: 5950
407
IntelliJ IDE Python TypeScript Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Neyla, welcome to the Ranch!

You forgot to tell us what the compilation error you're seeing is?
 
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic