Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: Problem with running, testing code in Eclipse

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem with running, testing code in Eclipse

    Hello,
    I'm new here and this is my first post. I have recently downloaded a program called Eclipse onto my computer to run Java programs, as well as Java itself. My problem is that, while I can get Eclipse to open, show projects and edit code, when I go to the "Run As" button to test it, nothing happens. I'am thing it has has to do with the program beiong run on a server, which I think its meant to do, but I'm working on a home desktop computer which is connected to a single NETGEAR modem. Can anyone help?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default re: Problem with running, testing code in Eclipse

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers, including a few "house rules" that will make you a more confident user of this forum.

    "Nothing happens" is hard to fix. Ensure you have the console view open at the bottom and can see if there are any error messages. If still no clue as to what's happening, post the code you're trying to run, and maybe we can see what's going on. Have you successfully done anything in your new setup? A HelloWorld.java program, for example? If you haven't tried that, please do and let us know the results.

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default re: Problem with running, testing code in Eclipse

    I don't think the problem is as much to do with the code as it has to do with the eclipse program. Whenever I open any program, the same thing happens. To be more specific, whenever I go to the "Run As" button at the top of the interface and select it, a window opens display three options, "Run on Server" and two "Ant Build" options, the first being for default settings, the second for configuration. What I think is the problem is that I need to create a server for the program to run on by selecting the "Server" option on the bottom screen, then rightclcking and selecting the "New" and "Server" options. Also, here is the code just for perusal, its is by no means done yet, and is its own problem for later.

    ex.:
    package assignment1;
     
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
     
    public class Assignment1 {
     
    	private static InputStreamReader input = new InputStreamReader(System.in);
    	private static BufferedReader reader = new BufferedReader(input);
     
    	// Variables
    		static int intRecordCount = 0;
    		static int intColumnCount = 0;
     
    		//2D arrays to hold a) record count(row)      b) 6 pieces of info (column)
    		static String[][] aryCustomers = new String[1][6];
     
    	/**
    	 * @param args
    	 */
    		//Main Method
    	public static void main(String[] args)
    	{
    	    MainMenu();
    	}
     
    	// Display user menu.
    	private static void MainMenu()
    	{
     
    	//Variables
    		int intMenuChoice = 0;
    		do
    		{
    			try
    			{
    				//Display Menu
    				//this will display the menu allowing the user to select a number between 1 and 5 to continue
     
    				System.out.println("=====================================================================================");
    				System.out.println("========   Main Menu   ==============================================================");
    				System.out.println(" 1. Add new customer information    ");
    				System.out.println(" 2. Display a count of addresses within a user defined geographical zone             ");
    				System.out.println(" 3. Display all information for customers within a user defined geographical zone    ");
    				System.out.println(" 4. Display a complete set of captured data                                          ");
    				System.out.println(" 5. Display a prioritised list of customer details within each geographical zone     ");
    				System.out.println(" 6. Display a count of customers within each geographical zone                       ");
    				System.out.println(" 7. Exit program                                                                     ");
    				System.out.println("=====================================================================================");
     
    				//this is to accept the menu choice
    				System.out.print("Enter Option :   ");
    				intMenuChoice = Integer.parseInt(reader.readLine());
     
    					//Selection based on option choice
    					if ( intMenuChoice == 1)
    					{
    						System.out.print("Can now accept Customer Information");
    						AcceptInformation();
    					}
    					else if ( intMenuChoice ==2)
    					{
    						System.out.print("Will now display a count of addresses within a user defined geographical zone ");
    						AddressCount();
    					}
    					else if ( intMenuChoice ==3)
    					{
    						System.out.print("Will now display all information for customers within a user defined geographical zone");
    						AreaCustomer ();
    					}
    					else if ( intMenuChoice ==4)
    					{
    						System.out.print("Will now display Complete Set of All Data");
    						DisplayAllCustomers();
    					}
    					else if ( intMenuChoice ==5)
    					{
    						System.out.print("Will now display a prioritised list of customer details within each geographical zone");
    						CustomerPriority();
    					}
    					else if ( intMenuChoice ==6);
    					{
    						System.out.print("Will now display a count of customers within each geographical zone");
    						AreaCount();
    					}
    					else if ( intMenuChoice ==7);
    					{
    						System.out.print("Goodbye ! ");
    					}
     
    					// this will display a message to show the menu choice entered
    					// is not between 1 and 7
     
    					else
    					{
    						System.out.print("Invalid Menu Selection");
    					}
     
     
    				}
    					catch(Exception ex) 
    				{
    					System.out.println ("Error : " + ex.getMessage());
    				}
    			} while (intMenuChoice != 7 );
    	}
    	// Menu choice 1. Add new customer information.
    		private static void AcceptInformation() 
    		try
    		{
    			//accept info
    			System.out.print("Record " + (intRecordCount + 1) + " Enter Name : ");
        		StrCustomerName[intRecordCount] = reader.readLine();
     
        		System.out.print("Record " + (intRecordCount + 1) + "Enter Address: ");
                strAddress[intRecordCount] = Integer.parseInt(reader.readLine());
     
                System.out.print("Record " + (intRecordCount + 1) + "Enter Postcode: ");
                intYearsService[intRecordCount] = Integer.parseInt(reader.readLine());
     
                System.out.print("Record " + (intRecordCount + 1) + "Enter Age: ");
                intAge[intRecordCount] = Integer.parseInt(reader.readLine());
     
     
    				// expand array for next customer
     
     
     
    		}
    		// Menu choice 2. Display the number of addresses within a geographical area
    		// defined by user.
    		private static void AddressCount() 
    		{
     
    					// Display Menu
    					// this will display the menu allowing the user to select an
    					// Area
     
     
    					// this is to accept the menu choice
     
     
    					// Selection based on option choice (switch)
     
     
    					// this will display a message to show the menu choice entered
    					// is not between 1 and 7
     
    		}
     
     
    		// Menu choice 3. Print all customer details for a user defined geographical
    		// area.
    		private static void AreaCustomer() 
    		{
    			//variables
     
     
    					// Display Menu
    					// this will display the menu allowing the user to select an
    					// Area
     
     
    					// this is to accept the menu choice
     
     
    					// Selection based on option choice
     
     
     
     
    					// this will display a message to show the menu choice entered
    					// is not between 1 and 7
     
    		}
     
     
    		// Menu choice 4. Display all Customer details.
    		private static void DisplayAllCustomers() 
    		{
     
    		}
     
    		// Menu choice 5. Print out a list of customers sorted by priority within
    		// each geographic area.
    		private static void CustomerPriority() 
    		{
     
    		}
     
    		// Menu choice 6. Display a count off all customers within each geographical
    		// area.
    		private static void AreaCount() 
    		{
     
    		}
     
    		// Calculate customer priority based upon area.
    		private static void CalculateCustomerPriority() 
    		{
     
     
    			// variables
     
    			// First sort customers into their geographic areas.
     
    		}
     
    		// Calculate the geographic zone for each customer.
    		private static void CalculateGeoZone(String PostCode) 
    		{
     
    		}
     
    		// Sort customers by age.
    		private static void SortCustomers() 
    		{
     
    			Arrays.sort(aryCustomers, new Comparator<String[]>() 
    			{
    				@Override
    				public int compare(String[] entry1, String[] entry2) 
    				{
    					String age1 = entry1[4];
    					String age2 = entry2[4];
    					return age2.compareTo(age1);
    				}
    			});
    		}
     
    		public static String[][] Expand(String[][] array, int size) {
     
    			String[][] temp = new String[size][6];
     
    			int rows = temp.length - 1;
    			int loop = 0;
     
    			while (loop < rows) {
    				temp[loop][0] = (array[loop][0]);
    				temp[loop][1] = (array[loop][1]);
    				temp[loop][2] = (array[loop][2]);
    				temp[loop][3] = (array[loop][3]);
    				temp[loop][4] = (array[loop][4]);
    				temp[loop][5] = (array[loop][5]);
    				loop++;
    			}
     
    			temp[rows][0] = "*";
    			temp[rows][1] = "*";
    			temp[rows][2] = "*";
    			temp[rows][3] = "*";
    			temp[rows][4] = "*";
    			temp[rows][5] = "*";
     
    			return temp;
     
     
     
    	}
     
    }

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default re: Problem with running, testing code in Eclipse

    The code you posted does not need to be run on a server and has at least one error that would prevent it from compiling and running. Around line 79 (in my editor, +2 in yours?), you began adding ';' at the end of the else if statements. Remove those as a start.

    Later you have a try without a catch. And there are other problems after that.

    Eclipse should be showing you these problems with red squigglies, red marks in the right editor frame, and similar indications at the offending line in the left side of the editor frame. You're not seeing them?

    Once you fix all syntax errors, try right clicking on the source file in the project explorer and selecting Run As, then Java Application. You may have to define your run configuration, or if either Eclipse or the environment are not set up properly, then you'll see other indications. Those indications may be there is no builder chosen or no compatible builder chosen, etc. If you get those indications, come back with what you see.

  5. #5
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default re: Problem with running, testing code in Eclipse

    No, the red squiggles aren't on the code, I think I may have to do what you said and define the run configuration.

  6. #6
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default re: Problem with running, testing code in Eclipse

    Greg is correct about the syntax errors. I don't think Eclipse would show the squiggly lines because it is not technically a syntax violation.

    if(condition);
    is the same as:
    if(condition) {
    ;
    }
    There is nothing syntactically "wrong" with either, except that it is code that does nothing...
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  7. #7
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default re: Problem with running, testing code in Eclipse

    Because the if clauses were a string of else/ifs, the red squigglies were shown for the else following an if statement terminated with a semi-colon. In that case, the following else became an 'else without if' syntax error.

    Micheal212, are you looking for more help to resolve your Eclipse setup issues? If so, I suggest you refer to your favorite web search tool and look for 'eclipse setup,' 'eclipse install,' 'eclipse config,' etc. Let us know if you have specific questions.

    Moving to the IDE section since I think learning to install/setup/use the IDE is the point of this question.

  8. #8
    Junior Member
    Join Date
    Jan 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with running, testing code in Eclipse

    OK, thanks a bunch for helping anyway.

Similar Threads

  1. Testing Constructor Overloading using Eclipse
    By michael.duffy31 in forum Java IDEs
    Replies: 8
    Last Post: September 2nd, 2013, 01:01 AM
  2. Replies: 21
    Last Post: June 12th, 2013, 11:33 AM
  3. Replies: 0
    Last Post: October 14th, 2011, 11:03 AM
  4. Error Running Java in Eclipse
    By steadyonabix in forum Java IDEs
    Replies: 1
    Last Post: September 3rd, 2011, 10:28 PM
  5. Random Errors Occurring When Running Game in Eclipse
    By WhenThCome4Me in forum Java IDEs
    Replies: 22
    Last Post: September 1st, 2011, 06:29 AM