Some compiling Error


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: Some compiling Error

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Posts
    16

    Some compiling Error

    I am getting tyhis error while compiling
    on terminal window
    java.lang.OutOfMemoryError
    My Comp config is
    2.28 ghz
    256 mb ram
    512kb L2

    Do i need to upgrade
    i use blue j 2.1.3

    i hv attached the file

  2. #2
    Join Date
    Sep 2006
    Posts
    68
    And where is it (file)?

  3. #3
    Join Date
    Aug 2006
    Posts
    16

    Question

    Quote Originally Posted by Uladzimir
    And where is it (file)?
    could not upload sorry
    ill try
    but plzz help me instead keeping jokes apart

  4. #4
    Join Date
    Sep 2006
    Posts
    68
    Hi!
    It might occurs in many cases. For example when you create an object in the infinite loop.
    PS: Without sources impossible to say where the bug.

  5. #5
    Join Date
    Aug 2006
    Posts
    16
    Quote Originally Posted by Uladzimir
    Hi!
    It might occurs in many cases. For example when you create an object in the infinite loop.
    PS: Without sources impossible to say where the bug.

    Heres My code
    Ill put two classes help on how to interconnect

    Class1-

    public class Library
    {
    String m[][] = new String [4][4];
    String t[][] = new String [1][4];
    public Library()
    {
    String t[][] = {{"Name"," Author"," Genre"," Published"},};

    String m[][] = {
    {"Psalm Of Life"," John Keats"," Religios"," Sun"},
    {"Daffodils"," Willium"," Nature"," Sun"},
    {"Julius Caesar"," Willium Shakespear"," Drama"," Morning Star"},
    {"Merchant Of Venice"," Willium Sakespeare"," Romantic Drama"," Morning Star"},
    };

    for(int row = 0 ; row<m.length ; row++)
    {

    for(int col = 0 ; col < m[0].length ; col++)
    {
    System.out.print(m[row][col]);
    }
    System.out.println();
    }

    System.out.println(m.length + " " + m[0].length);

    }}


    Class2-


    import java.io.*;
    public class Borrow
    {
    InputStreamReader isr = new InputStreamReader (System.in);
    BufferedReader br = new BufferedReader(isr);


    public void bookDetails()throws IOException
    {
    String t[][] = {{"Name"," Author"," Genre"," Published"},};

    String m[][] = {
    {"Psalm Of Life"," John Keats"," Religios"," Sun "},
    {"Daffodils"," Willium"," Nature"," Sun "},
    {"Julius Caesar"," Willium Shakespeare"," Drama"," Morning Star"},
    {"Merchant Of Venice"," Willium Sakespeare"," Romantic Drama"," Morning Star"},
    };

    for(int row = 0 ; row<m.length ; row++)
    {

    for(int col = 0 ; col < m[0].length ; col++)
    {
    System.out.print(m[row][col]);
    }
    System.out.println();
    }}
    public void option()throws IOException
    {
    int a = 0;
    boolean flag = false;
    System.out.print(" 1. Want to borrow a book??");
    System.out.print(" 2. Go Back ");
    System.out.print(" Please enter the number corresponding your choice ");
    String temp = br.readLine();
    do{
    try
    {
    flag = false;
    a = Integer.parseInt(temp);
    System.out.print(" Please enter the number corresponding your choice ");

    }
    catch (NumberFormatException e)
    {
    System.out.print(" You have entered an invalid character ");
    flag = true;
    }}while(flag);

    if(a!=1 || a!=2)
    {
    System.out.print(" Please enter the number corresponding your choice from the optoins given only ");
    option();
    }
    else
    if(a == 1)
    bookDetails();
    }}



    I get tht error while compiling class 2 and tht is just 25% of the code i hv to actually write

  6. #6
    Join Date
    Sep 2006
    Posts
    68
    Works for me... Try to add following parameters to java compiler
    -Xms256M -Xmx256M

  7. #7
    Join Date
    Aug 2006
    Posts
    16

    Talking

    Thnx but noe there is another problem
    Whwen i cr8 the object it goes into an infinite loop even when i enter correct values plzz check and reply thnx?

  8. #8
    Join Date
    Aug 2006
    Posts
    16
    Quote Originally Posted by Uladzimir
    Works for me... Try to add following parameters to java compiler
    -Xms256M -Xmx256M
    How do you add this and where can i find a java compiler
    I am a beginner and am learning java because i hv to do it for my boards so i realy have no idea of anything outside my syllabus
    Please provide steps on how to resolve the porblem

  9. #9
    Join Date
    Sep 2006
    Posts
    68
    Hi!
    1) Compile and runtime errors are not the same
    2) Please add main method. What I should launch?

  10. #10
    Join Date
    Aug 2006
    Posts
    16
    Quote Originally Posted by Uladzimir
    Hi!
    1) Compile and runtime errors are not the same
    2) Please add main method. What I should launch?

    I hvnt finish writing the complete code
    Class 1 will contain main method from where you can login
    Code for login only--
    public void login()throws IOException
    {
    System.out.println("Enter Username");
    String userName = br.readLine();
    System.out.println("Enter password");
    String psswrd = br.readLine();
    userName.trim();
    psswrd.trim();
    boolean check = true;
    int a = userName.length();
    int b = psswrd.length() ;
    String temp = "";
    if (a == b)
    for(int i = b-1; i>=0 ; i--)
    {
    temp = temp+psswrd.charAt(i);
    }
    System.out.println(temp);
    if(userName.equalsIgnoreCase(temp))
    System.out.println("Password Accepted. Thank You For Logging in "+userName);
    else
    {
    System.out.println("You have entered an invalid password.Please call method again and re-enter your details.");
    System.out.println("Password Forgotten?? -- Contact System Administrator at sa@library.org");
    }

    How can i make this method static???
    Code:
    Please help!!

  11. #11
    Join Date
    Sep 2006
    Posts
    68
    1. >> How do you add this and where can i find a java compiler..
    What IDE are you using?

    2.
    userName.trim(); // illegal; this line do nothing
    userName = userName.trim(); // correct

    3. >> How can i make this method static???
    public static void login() throws IOException {

    But as I understand compiler can't see "br" varable?!!
    If yes then change your code to
    static InputStreamReader isr = new InputStreamReader(System.in);
    static BufferedReader br = new BufferedReader(isr);

    BWT why are you and other students like to use static methods? This is not good approach.Very rare method should be a static. The overuse of static members can lead to problems similar to those experienced in languages like C and C++ that support global variables and global functions.

Similar Threads

  1. I can't link FreeImage to C#
    By mesh2005 in forum .NET
    Replies: 1
    Last Post: 03-06-2006, 09:16 AM
  2. Writing in HKEY_LOCAL_MACHINE...Access is denied
    By Martin in forum VB Classic
    Replies: 22
    Last Post: 12-03-2001, 04:53 AM
  3. Returning errors from SQL Server Stored Procs
    By Khalizan in forum VB Classic
    Replies: 1
    Last Post: 11-28-2001, 02:32 AM
  4. WinForm Compile Error
    By Robert in forum .NET
    Replies: 1
    Last Post: 10-24-2000, 12:38 PM
  5. Replies: 0
    Last Post: 04-07-2000, 10:19 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center