Why won't it compile?

I have four classes. I have been told that i can compile the main one and the rest will compile by them selves. This doesn't seem to work. I can't even compile then seperatley. Any ideas why they won't work?
Main Code;
public class TestBoundedBuffer {
public static void main(String args[] ) {
// just create the two threads and the bounded buffer
BoundedBuffer b = new BoundedBuffer();
ProduceIntegers p = new ProduceIntegers(b);
ConsumeIntegers c = new ConsumeIntegers(b);
p.start();
c.start();
THREE OTHER CLASSES:
public class BoundedBuffer {
private static final int BUFFER_SIZE = 5;
private int count, in, out;
private int [] buffer;
public BoundedBuffer() {
count = 0;
in = 0;
out = 0;
buffer = new int[BUFFER_SIZE];
public synchronized void enter(int item) {
while (count == BUFFER_SIZE) {
try {
wait();
     catch (InterruptedException e) { }
// add an item to the buffer
count++;
buffer[in] = item;
in = (in + 1) % BUFFER_SIZE;
notify();
public synchronized int remove() {
int item;
while (count == 0) {
try {
wait();
     catch (InterruptedException e) { }
// Remove an item from the buffer
count--;
item = buffer[out];
out = (out + 1) % BUFFER_SIZE;
notify();
return item;
NEXT CLASS:
public class ProduceIntegers extends Thread {
private BoundedBuffer buff;
public ProduceIntegers( BoundedBuffer b ) {
buff = b;
public void run() {
for (int i=0; i<100; i++) {
System.out.println("Produced " + i);
buff.enter(i);
NEXT CLASS:
public class ConsumeIntegers extends Thread {
private BoundedBuffer buff;
public ConsumeIntegers( BoundedBuffer b ) {
buff = b;
public void run() {
for (int i=0; i<100; i++) {
int item = buff.remove();
System.out.println( "Consumed " + item);

1) each of the 4 classes needs to be written in their own .java file, and in the same directory as the main .java file
or
2) TestBoundedBuffer.java can contain all the code for the other 3 classes, but you have to remove "public" as the class accessor.
ie
public class ProduceIntegers extends Thread {
becomes
class ProduceIntegers extends Thread {

Similar Messages

  • Help...Why won't this compile?

    Why won't this compile?
    Here is my code:
    import java.util.Calendar;
    import javax.swing.JOptionPane;
    public class GetAge{
    public static void main(String[] args){
    int month=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what month(MM) you were born:"));
    int day=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what day(dd) you were born:"));
    int year=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what year(yyyy) you were born:"));
    Calendar rightNow = Calendar.getInstance();
    int year2 = rightNow.get(Calendar.YEAR);
    int day2 = rightNow.get(Calendar.DATE);
    int month2 = rightNow.get(Calendar.MONTH)+1;
    int years = year2-year-1;
    int months = month2-month+12;
    if(day2 >= day)
       int days = day2-day;
    else
       days = day-day2+8;
    JOptionPane.showMessageDialog(null,"You are: " + years
    + " years " + months + " months and " + days + " days old.");
    }

    What you're doing is using days after the if statement; without curly braces only a valid statement is allowed.
    But if you add curly braces, days will be available only in the if block.
    So what you should do is:
    import java.util.Calendar;
    import javax.swing.JOptionPane;
    public class GetAge{
    public static void main(String[] args){
    int month=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what month(MM) you were born:"));
    int day=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what day(dd) you were born:"));
    int year=Integer.parseInt(JOptionPane.showInputDialog
    (null,"Enter what year(yyyy) you were born:"));
    Calendar rightNow = Calendar.getInstance();
    int year2 = rightNow.get(Calendar.YEAR);
    int day2 = rightNow.get(Calendar.DATE);
    int month2 = rightNow.get(Calendar.MONTH)+1;
    int years = year2-year-1;
    int months = month2-month+12;
    int days = 0;      //declare here
    if(day2 >= day)
       days = day2-day;  //...and use here
    else
       days = day-day2+8;   //..and here
    JOptionPane.showMessageDialog(null,"You are: " + years
    + " years " + months + " months and " + days + " days old.");
    }

  • Why won't anything compile?

    Whenever I try to compile anything, I get 100 errors and 206 warnings, saying:
    java/net/URI.java [2,572:1] warning: as of release 1.4, assert is a keyword, and may not be used as an identifier
    assert false;
    ^
    and
    java/net/URI.java [2,572:1] not a statement
    assert false;
    ^
    I am not using java/net/URI.java or importing any programs, so I do not understand why the compiler is giving me errors and warnings.

    Which version of JDK are you running?
    What has changed all of a sudden? If this behavior hasn't happened before, something had to have triggered it.
    Have you installed Oracle? It tends to install it's own JDK. Have you installed/uninstalled anything else? Got any old JARs hiding in the jre/lib/ext directory that you've forgotten about? They could be conflicting with something else that you've got on your machine.
    It's impossible to tell based on the little information you've provided. That's where I'd advise that you start looking. Something changed - it's up to you to remember what it is and put it right. - MOD

  • Why won't this compile ?

    CREATE OR REPLACE FUNCTION FN0003_GetDisabilityCode
    RETURN CHAR(8);
    IS 
    DisabilityCode CHAR(8);
    BEGIN
    DisabilityCode := '00000000';
    RETURN DisabilityCode;
    END FN0003_GetDisabilityCode;

    Same as parameters, return datatype can't have length/precision and get rid of semi-colon. Change it to:
    CREATE OR REPLACE FUNCTION FN0003_GetDisabilityCode
      RETURN CHAR
       IS 
    DisabilityCode CHAR(8);
       BEGIN
    DisabilityCode := '00000000';
            RETURN DisabilityCode;
    END FN0003_GetDisabilityCode;
    SY.

  • Why won't my L4P and LKS files launch on customer's computer?

    Events make me almost sure I caused this, but would appreciate help if there's a way to prevent doing this all over again...
    Customer had a process file that was running fine, but with an increasing number of staff with access to Lookout he wanted user accounts created and security levels assigned to numerous Lookout objects (accounts and objects were all at default settings). He emailed me the LKS and L4P files, I edited them, and emailed them back. 
    The L4P and LKS launch fine on my computer, but won't on the customer's. On the customer's computer, launching the LKS file produces a compile error, but doesn't identify the error. I've also emailed the files to a colleague, who replied he had no problem either. Should mention colleague (like me) is running North American Win XP. 
    Files were generated in Ver 6.02(1) on WinXP machines, and bench tested fine on a Ver 6.1 Runtime also under XP.
    The customer is located in Poland, has a Ver 6.1 Runtime, and is running it on a Win NT machine. 
    So assuming for a moment I caused this anomaly during my editing, why do the files not work at customer's location and why won't the compiler identify what it is?
    More to the point, how do I fix this? 
    JW_Tech 

    Yo, JPhillips:
    Thanks for the tip. Took a look at the err file (see for yourself)... 
    Lookout Process File Compiler Version 6.1 (build 27)
    Copyright National Instruments 1992-2007  All rights reserved.
    cannot open source file: C:\Program Files\National Instruments\Lookout 6.1\cedrob.lks 
    This is the same folder where the unedited files WILL work. 
     Ryan, I've uploaded the cedrob2.zipfile to the ftp site. Would appreciate you having a look at it.
    There is certainly a mystery here. If I'm working at a site where the OS is all English, I weigh how much editing I might have to perform and consider moving my Integrator license from my laptop to the customer's computer (to take advantage of the bigger screen, mouse, keyboard and the on-line editing of Lookout) for the duration of the session. In this case, I was at the site (in Poland) in August and since Polish is not my strong suit, I did all my editing on my laptop and transfered the files to customer's computer via memory stick. Everything worked fine during all that, so emailing the files should not be any different, yes? 

  • Why won't it package?????

    I'm using the new Tomcat 5.0 and apparently it won't read a class unless it's part of a package.
    I'm trying to compile a very simple Bean.
    package mypackage;
    public class StringBean {
    private String message = "No message specified";
    public String getMessage() {
    return (message);
    public void setMessage(String message) {
    this.message = message;
    With the "package mypackage;" I expect it to put it into mypackage directory but all it does it create the .class file in the same directory I'm already in. I'm using Java 1.4.1.
    Why won't it package???

    you can compile java files anywhere, you have to put the class in the correct place to use them during runtime. typically you have a src directory with all of your java files in the correct directory stucture for you rpackages and then a classes directory with the correct directory stucture for you packages. You use a build tool like ant to do the compile and place the class files in the classes directory.

  • HT3702 I only download things that are free from App Store, but sometimes it doesn't let me download something saying there is a problem with a previous purchase?  So why won't it let me??

    Why won't the App Store let me download things that are free, just because I don't have money on my card sometimes, it's free so I just don't get it??

    You can try to make a new account on iTunes Store if you didnt have yet.
    I had the same problem with iTunes Store, the only thing you can do is to put some money on that credit card you are using with you account. iTunes Store already keeping some money for the last purchase you made you can see all info on the Account option and then Purchase history ...

  • I am a new iPhone 4s owner. I have a tone in iTunes that I downloaded from the web as a m4r file. Why won't it sync to my iPhone so I can set it as a ringtone.

    I am a new iPhone 4s owner. I have a tone in iTunes that I downloaded from the web as a m4r file. Why won't it sync to my iPhone so I can set it as a ringtone?
    Lois

    Yes, the tone is available and checked in iTunes under the Tones library.
    Yes, it is also listed under the Tones tab for my iPhone, but it is grayed out.
    Yes, tones are selected under "sources" in General Preferences, along with everything else.
    SyncTones was NOT selected under the Tones tab for my iPhone. I did so and it synced.
    Thanks for your help!
    Lois

  • Why won't Apple give out the unlock code for an iPhone 3Gs when the contract was honored and I am still an AT

    Why won't Apple give out the unlock code for an iPhone 3Gs when the 2  year contract was honored and I continued to be an AT&T customer with an iPhone 4. I wanted my old 3gs unlocked so my daughter could use it overseas when she is deployed. AT&T service over there *****, the international plan was not worth it. The individual SIM cards per country are much more reliable and cheaper. Teslestial in Iraq and Afghanistan, Telecom in Croatia,Vodafphone in Germany and Italy.  Why Apple will not unlock these phones for our military to utilize is incomprehensible to me.  These young men and women are fighting for these Apple people to go to work every day, safe, to live lives they have become accustom to yet releasing a phone to use on another network they can't do at least for the military.... WHY APPLE??  WHY?   A good excuse not some of the many lame excuses I have received on the phone many times. AT&T states it is Apple that will not allow them to unlock the phones...  Please tell me why?  All I want Is my daughter to have a phone I trust, to be able to call me when she is given the free time to do so and I trust the apple phone.
    Apple, please reconsider your stance on this issue.  I am having a hard time understanding why you will not unlock the iPhone. 
    A simple code could allow me to talk to my daughter while fighting for our country the Great USA.  Apple should be on the front line and enabling those fighting for our life, liberty and pursuit of happiness to use unlocked phones on reliable local GSM networks.
    I honestly hope that someone who has some sort of authority to begin allowing the release of unlock codes, and not forcing people to unlock their phones with some program produced by some hack just to be able to use your wonderful phone.  That is is in a nutshell, People love the iPhone so much that they want the ability to use it on the most reliable GSM carrier available to them.  That should be a major compliment. Even men and women on the front line want your phone. I agree, my service is not the best where I live either, love the GSM technology so stay with it, but if I had the ability to change to the other GSM network that has much better coverage in this area of the country I would change. To change now I would not have my iPhone and that I will not part with. 
    Apple, please reconsider opening up the lock code and allow your gem of a phone to be used by many more people in many more areas and most importantly overseas fighting for our country.  I know if this is really thought about Apple would understand and come to the conclusion to release the unlock codes, and stop the people from hacking in to use the iPhone on other networks.
    I would love for my daughter to be able to use my iPhone 3gs while fighting for our Free country.
    A response would be appreciated.
    Thank you.
    An Apple customer for 10 years, phones and computers.
    P

    Defiled:
    I did sign a two year contract and completed that contract. The 3gs is no longer in service. My daughter is going overseas to protect you and your family. I was attempting to find a way for her to have a reliable phone that could offer her some connection with home as she travels through the middle east.  She travels in missions all over.
    At&T unlocks other phones of theirs why not the iPhone?  AT&T says that Apple will not give them the code, it is not the carrier.  If I would have known this situation would have come up I would have bought and unlocked 3gs phone"Deggie" .  My main complaint is that Apple has not good excuse as to why they will not allow their phones to be unlocked from services well, AT&T .  I bought the phone full price, completed the contract terms, even went for and iPhone 4 with another2 year contract, along with owning an apple computer... I love the product.  My main issue is give me a good answer as to why you won't allow a phone to be unlocked. It doesn't hurt Apple, People still have to buy the phones from them, and use their App store and iTunes.
    Sorry, just upset about my daughter heading over there, boots on the ground, and just pray she will be safe. Would have liked to facetime her while she is in the airports and in specific areas allowed for that.
    Please don't come down on me for asking this question. I understand all the contracts etc.... but to single out the iPhone specifically to not unlock after contract is over does not seem fair.
    Thank you for your responses.

  • Using Mac OS 10.8.5 why won't disk image from Utilities mount to open a .dmg file?

    Using Mac OS 10.8.5 why won't DiskImage from Utilities mount in order to open a .dmg file?

    Select the .dmg file and double-click it. FWIW, there's no DiskImage thing in Utilities on any of my boot volumes.
    27" i7 iMac (Mid 2011) refurb, OS X Yo (10.10), Mavs, ML & SL, G4 450 MP w/10.5 & 9.2.2

  • ITunes says my computer isn't authorized to play one song, but all the rest of them work. The song works on my iPad so why won't it work on my computer or my iPod?

    iTunes says my computer isn't authorized to play one of the songs I just downloaded, but all the rest of them work. That song works on my iPad so why won't it work on my computer or my iPod? It says my computer isn't authorized to play that song so I type in my password and it pops up with a menu saying my computer is already authorized and it skips to the next song. No matter what I do it won't play that song on my laptop or my iPod.

    Could be a Corrupt download of that song...
    If you live in a Region that allows re-downloading Music...
    Delete the Song(s) and re-download...
    See Here  >  Download Past Purchases
    http://support.apple.com/kb/HT2519
    If not... Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

  • Why won't my iphone 3gs charge even though it is plugged in?

    Hi guys, so I've had my 3gs for nearly 2 years. A couple of weeks ago I noticed that charging it wasn't going easy. When my iphone shuts down from no battery life and I plug it in to charge, it charges enough to turn itself back on, but when it eventually turns back on it won't charge anymore? Even though it is still plugged in and switched on by the plug. So I have to take out the USB, turn off the switch to the plug, turn the switch back on, plug the USB back in and it charges again.
    BUT, recently not even that does it. I've tried different plug sockets, i've rebooted it. I've tried leaving the USB cable in and just turning on and off the plug switch.
    So at the moment it's just going through a circle of running out of battery, charging and turning itself back on, having 4% battery and dying again and repeating.
    So I googled my problem and didn't really find a solution. I mean the plug and USB cable are fine. Clearly it charges fine because it charges enough to turn itself back on when it's shut down. 
    I found out that when the iphone is plugged in but turned off it still charges so I tried this when it started itself up again, and it charges!!
    But why won't it charge when the phone is on and plugged in??

    Hi waplington123,
    If your iPhone will not start up unless connected to power, you may want to troubleshoot using the steps in this article -
    iPhone: Hardware troubleshooting
    http://support.apple.com/kb/TS2802
    Specifically -
    Will not turn on, will not turn on unless connected to power, or unexpected power off
    Verify that the Sleep/Wake button functions. If it does not function, inspect it for signs of damage. If the button is damaged or is not functioning when pressed, seek service.
    Check if a Liquid Contact Indicator (LCI) is activated or there are signs of corrosion. Learn about LCIs and corrosion.
    Connect the iPhone to the iPhone's USB power adapter and let it charge for at least ten minutes.
    After at least 30 minutes, if:
    The home screen appears: The iPhone should be working. Update to the latest version of iOS if necessary. Continue charging it until it is completely charged and you see this battery icon in the upper-right corner of the screen . Then unplug the phone from power. If it immediately turns off, seek service.
    The low-battery image appears, even after the phone has charged for at least 20 minutes: See "iPhone displays the low-battery image and is unresponsive" symptom in this article.
    Something other than the Home screen or Low Battery image appears, continue with this article for further troubleshooting steps.
    If the iPhone did not turn on, reset it while connected to the iPhone USB power adapter.
    If the display turns on, go to step 4.
    If the display remains black, go to next step.
    Connect the iPhone to a computer and open iTunes. If iTunes recognizes the iPhone and indicates that it is in recovery mode, attempt to restore the iPhone. If the iPhone doesn't appear in iTunes or if you have difficulties in restoring the iPhone, see this article for further assistance.
    If restoring the iPhone resolved the issue, go to step 4. If restoring the iPhone did not solve the issue, seek service.
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Why won't iTunes 11.0.1 sync my Podcasts to my 3rd Gen iPod Touch on IOS 6.0.1?

    Why won't iTunes 11.0.1 sync my Podcasts to my 3rd Gen iPod Touch on IOS 6.0.1?  I'm running iTunes on my MacBook with Mac OSX 10.6.8.  I've checked to make sure in iTunes that the Podcast Sync box is checked and it is.  I've tried checking communities and tried several suggestions and nothing seems to work for me.  Everything else syncs except Podcasts.  I can't figure it out. Any suggestions to get Podcasts syncing to my iPod Touch again?  Thanks!

    One other step I've tried was removing and completely reinstalling the playlist to the iPod. That cleared up the problem for about two days.

  • Why won't Adobe reader no longer let me view previously download (from Safari) pdf's? I am running OSX 10.8.5 and have uninstalled and reinstalled latest version of Reader?

    Why won't Adobe reader no longer let me view previously download (from Safari) pdf's? I am running OSX 10.8.5 and have uninstalled and reinstalled latest version of Reader. I get this error message "Adobe Reader could not open 'OD Test Bed Proposals_0.pdf' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."  I have tried changing the 'open with' options too. Thanks

    Try this:
    Go to: Mac HD/Library/Internet Plug-ins
    Trash the AdobePDFViewer.plugin and AdobePDFViewerNPAPI.plugin files
    Empty the trash
    Relaunch Safari. You can now download undamaged PDFs.

  • Why won't icloud work with windows vista anymore?

    why won't icloud work with windows vista anymore?

    I had to re-install after the newly released iTunes - for Vista it does work with iClud 2 - not 3. You can download from this site.

Maybe you are looking for

  • In 10.4, an internet audio file now opens with Quicktime?

    Many thanks in advance for your attention. When I was using 10.3 (and before), when clicking on an audio file on the internet, RealPlayer 9 automatically opened. One could see the % of the file being downloaded and then (quickly), one would automatic

  • Itunes 7.02 unstable?

    Downloaded itunes 7.02(15), and installed. Freezing up while trying to load music to Ipods. Added 1 GB ram and installed OSX 10.4 upgrade, still freezing up. Re-installed itunes, still freezing up. Lots of posts about itunes 7.0 freezing up...is ther

  • BADI for Vendor Invoice after Posting to send a mail to vendor

    Hi, My requirement Is like this. I have to send a mail to vendor after the Invoice for vendor is Posted. For dat I am searching for a badi to implement after the invoice is successfully posted. Please give some solution about this. Regards, Jyoti..

  • How to get FaceTime on iPhone purchased in UAE

    Hi. I had purchased an iPhone 4S in UAE , where FaceTime is probably not allowed. Now that I am in United Kingdom, how can I get it on my iPhone ? I have restored it to factory settings but no success. Anyone with a similar experience?

  • How Do I Get This Guitar Sound

    How do I get this guitar sound? What effects is he using? Can I get it with Garage Bands sounds?? Paul W. http://www.youtube.com/watch?v=E5sJVXXYVPA