Page 1 of 2 12 LastLast
Results 1 to 20 of 21
Like Tree1Likes

Thread: Compile Error: Could Not Open

  1. #1
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Compile Error: Could Not Open

    I am trying to run my first program on a new laptop as my old one crashed. I got this error and not sure what it means: could not open 'C:\Program Files\Java\jre7\lib\amd64\jdm.cfg'

  2. #2
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    I am trying to compile a package example from a textbook.

    Here is the code:

    // A simple package
    package MyPack;

    class Balance {
    String name;
    double bal;

    Balance(String n, double b) {
    name = n;
    bal = b;
    }

    void show() {
    if (bal<0)
    System.out.print("--->");
    System.out.println(name + " : $" + bal);
    }
    }

    class AccountBalance {
    public static void main(String args[]) {
    Balance current[] = new Balance[3];

    current[0] = new Balance("K. J. Fielding", 123.23);
    current[1] = new Balance("Will Tell", 157.02);
    current[2] = new Balance("Tom Jackson", -12.33);

    for(int i = 0; i < 3; i++)
    current[i].show();
    }
    }

    The name of my file is AccountBalance.java and the directory is C:\Java\MyPack. I have my cmd directory as C:\Java and typed in java MyPack.AccountBalance and it gives me that error.

  3. #3
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Compile Error: Could Not Open

    @BiCure:
    Are you sure that here 'C:\Program Files\Java\jre7\lib\amd64\jdm.cfg' is 'jdm.cfg', because I think that there should be 'jvm.cfg' file?
    Fubarable likes this.

  4. #4
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    You are right, the error is stating jvm not jdm, sorry for the typo.

  5. #5
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Compile Error: Could Not Open

    Is this error was in Eclipse IDE, or in Netbeans, or in something else?

    Java allows several JRE/JDK to be installed at the same time, and IDE allows you to select the one to use with your project in Preferences.

  6. #6
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    I am just using notepad.

  7. #7
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    And trying to run in command prompt.

  8. #8
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Compile Error: Could Not Open

    If you have Windows OS you should try something like this:

    My Computer -> clickRightButton -> Properties -> Advanced -> Environment Variables -> (system Variables) click on Path -> edit Path and in Path you should write this:

    ;C:\Program Files\Java\jre7\bin;C:\Program Files\Java\jre7\lib

    and you should delete previous values in that Path that is similar to this values.

  9. #9
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    My program folder MyPack is located in bin. Is this correct? I have my file AccountBalance.java in MyPack in the bin folder. Then when I open cmd and try to compile I get the location to the bin folder then type javac MyPack.AccountBalance.java and get an error saying file not found.

  10. #10
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    C:\Program Files\Java\JDK\bin> javac MyPack.AccountBalance.java is how it looks in cmd

    It says javac: file not found: MyPack.AcccountBalance.java

  11. #11
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    I have gotten my program to run but the purpose of the exercise was to learn how packages work. I had to delete the package part of it to get it to run. Can you help me with how packages work? I thought I understood from my textbook but I get an error that way and can only run it when it is not part of a package.

  12. #12
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    Using the program above, it says put AccountBalance.java in a directory called MyPack. I made a folder in bin called MyPack and saved AccountBalance.java inside

    It then says, compile the file and make sure the resulting .class is also in the MyPack file. Then try executing the AccountBalance class using the following command line --> java MyPack.AccountBalance. I have C:\Program Files\Java\JDK\bin as my directory. When I have the package = MyPack; included in my program and type javac MyPack.AccountBalance.Java it will come up with an error: file not found myPack.AccountBalance.java

  13. #13
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Compile Error: Could Not Open

    ^ Do not use java MyPack.AccountBalance, but use java MyPack/AccountBalance.

    Do not use javac MyPack.AccountBalance.java, but use java MyPack/AccountBalance.java

    I think that it should work.
    Last edited by cselic; 07-09-2012 at 02:59 AM.

  14. #14
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    Compile Error: Could Not Open-untitled.png

    It worked to compile, but when running I got this error. Too long to type, took screen capture.

  15. #15
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    With LoL in the background haha, didn't feel like edit.

  16. #16
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default Re: Compile Error: Could Not Open

    ^Please copy + paste your error on this thread.

  17. #17
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    Not sure how to copy paste out of cmd.

  18. #18
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    It is in that screen capture.

  19. #19
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,224
    Rep Power
    20

    Default Re: Compile Error: Could Not Open

    1. Do not stick your code in the JDK folder.
    You should be working in your own directory, probably in your user docs or similar.
    Then you need to go through the Java tutorials at Oracle to try and get them compiling, probably the basics ones.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  20. #20
    BiCure is offline Member
    Join Date
    Jul 2012
    Posts
    17
    Rep Power
    0

    Default Re: Compile Error: Could Not Open

    Well thanks for the link to get my folder straight that was easy. Also, I realized my error. After figuring out the path problems in my first endeavor and deleting the package name to get it to compile in the first place, I realized I named my package myPack instead of MyPack when I put it back in. Dumb of me. Thanks cselic and Tolls!

Page 1 of 2 12 LastLast

Similar Threads

  1. Compile error :(
    By Astralogic in forum New To Java
    Replies: 10
    Last Post: 07-22-2013, 03:26 PM
  2. i get this error during compile
    By Bibin in forum New To Java
    Replies: 1
    Last Post: 12-24-2011, 09:43 AM
  3. compile error
    By angryredantz in forum New To Java
    Replies: 1
    Last Post: 01-23-2009, 11:44 PM
  4. Compile Error - Please Help!!
    By AJ2009 in forum New To Java
    Replies: 10
    Last Post: 01-04-2009, 04:59 PM
  5. compile error
    By dirtycash in forum New To Java
    Replies: 6
    Last Post: 12-12-2007, 07:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •