Having problems using a Switch statement in Java - java
I'm making a Character Creator for fun and I seem have run into yet another java problem! I tried googling around for a bit but I didn't seem to find a working solution... I'm trying to use a switch statement for the compiler to output certain information depending on what class (Knight, Archer, Mage) the user chose, but when inputting my code I get error messages
My code so far (cleaned up a bit) is :
String name;
String className;
int attPoints;
System.out.println("Welcome to 'GameName's' Character Creator 2.0!\n");
Thread.sleep(500);
System.out.print("First off, what do you want your characters name to be? \n\nName : ");
name = Scan.nextLine();
Thread.sleep(500);
System.out.print("\nYou are now to be known as "+ name + "!");
System.out.print("\n\n" + name + ", what class do you want to be? ");
System.out.print("\n\nClasses available :\nKnight");
Thread.sleep(1500);
System.out.print("\nMage");
Thread.sleep(300);
System.out.print("\nDruid");
Thread.sleep(300);
System.out.print("\nNinja");
Thread.sleep(300);
System.out.print("\nArcher");
Thread.sleep(300);
System.out.print("\nAdventurer");
Thread.sleep(300);
System.out.print("\nBerserker");
Thread.sleep(300);
System.out.print("\n\nClass : ");
className = Scan.next();
Class userClass = Class.valueOf(className);
Thread.sleep(500);
System.out.println("\nCongratulations! Your class is now : "+ className + "!");
Thread.sleep(500);
// This is where I get an error.
// - Syntax error, insert "enum Identifier" to complete EnumHeaderName
// - Syntax error, insert "EnumBody" to complete BlockStatement
// - Syntax error on token "void", # expected
public void setClass()
switch (Class) {
case Knight:
System.out.println(" Various lore about knights ");
break;
}
}
I THINK I may be trying to create a class inside another class - but when I tried putting it outside it got another error...
Also, I have an int called attPoints, and after I choose a class I want to add 10 to it, but unsure how.
You're switching on Class which is a Java type. Take a look at this tutorial: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
You probably want to do something like:
switch (userClass) {
case Class.KNIGHT:
System.out.println(" Various lore about knights ");
break;
}
Related
Selenium replace value for the input field with sendKeys() method
I have an unexpected issue with the sendKeys() method: A long time before it all worked fine, but unexpectedly the (certain(!)) values are replaced when the code tries to set data into the input field: For example, if I set value USER_NAME into the field, value replaced with /tmp/7d7b7...../upload123...file/USER_NAME. As we can see - some path was added into the USER_NAME value. I added logs to the method and we can see a moment when the value was replaced: clearInputFld(inputFld); Log.info("INSIDE clearAndTypeIntoInputField() ---------> value after clearing: " + inputElement.getAttribute("value")); Log.info("INSIDE clearAndTypeIntoInputField() ---------> value to set: " + value); inputElement.sendKeys(value); Log.info("INSIDE clearAndTypeIntoInputField() ---------> value after set: " + inputElement.getAttribute("value")); Output: INSIDE clearAndTypeIntoInputField() ---------> value after clearing: INSIDE clearAndTypeIntoInputField() ---------> value to set: USER_NAME INSIDE clearAndTypeIntoInputField() ---------> value after set: /tmp/7d7b7...../upload123...file/USER_NAME So we can be sure - value sets exactly at the moment when value sets into the field. Important to know, and conclusions: Not all users replaced - Only several certain users! So I suppose a part of users is cached. But I do not understand the process with which this happens, why this happens, and where these users might be cached. I also restarted the docker, so it seems the problem is not in the automatic side. Is it possible that this issue occurs via the backend or UI part?
It looks like there is a script running on the page that changes the input you type, as this is a password field. What I suggest is that you use the Robot object to mimic keyboard strokes. First click on the text field using Selenium, then launch the Robot code (use package Java.awt): Robot robot = null; try { robot = new Robot(); for (char c : textToType.toCharArray()) { int keyCode = KeyEvent.getExtendedKeyCodeForChar(c); if (KeyEvent.CHAR_UNDEFINED == keyCode) { logger.error("Key code not found for character '" + c + "'"); } else { try { robot.keyPress(keyCode); robot.delay(10); robot.keyRelease(keyCode); robot.delay(10); } catch (Exception e) { if (c == '_') { robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_MINUS); robot.keyRelease(KeyEvent.VK_MINUS); robot.keyRelease(KeyEvent.VK_SHIFT); } if (c == ':') { robot.keyPress(KeyEvent.VK_SHIFT); robot.keyPress(KeyEvent.VK_SEMICOLON); robot.keyRelease(KeyEvent.VK_SEMICOLON); robot.keyRelease(KeyEvent.VK_SHIFT); } } } } robot.keyPress(KeyEvent.VK_ENTER); } catch (Exception ex) { logger.error(ex.getMessage()); }
According to Logs, I think there is something come with the value. Suggest trying : Get the changed text, do some operation, fill it back string[] temp; temp = (inputElement.Text).Split('/'); inputElement.Sendkeys(temp(temp.Length - 1));
adding inner label gives error on string variable
I have a special case in my code where a label would fix possible issues start: String zipCodes1 = "90019,90036,90016,90005,90010,90018,90020,90004,90048,90035,90211,90006,90038,90008,90089,90062,90007,90028,90034,90212,90232,90231,90233,90057,90209,90213,90070,90029,90069,90015,90056,90037,90017,90067,90043,90046,90026,90071,90014,90230,90064,90099,90302,90189,90011,90030,90050,90051,90052,90053,90054,90055,90060,90072,90074,90075,90076,90078,90080,90081,90082,90083,90086,90087,90088,90093,90024,90009,90013,90068,90090,90079,90012,90210,90021,90025,90306,90307,90308,90309,90310,90312,90311,90095,90305,91608,90027,90084,90066,90301,90073,90094,90047,91522,91604,90039,90003,90044,91602,90031,91204,91523,90033,90295,90001,90045,90077,91521,90065,90096,90404,90292,90405,90303,90058,90294,90304,90291,91209,91221,91222,91224,91225,91226,91210,91205,90023,91203,91601,91393,91506,91423,90063,90002,90403,90255,91607,91603,91609,91610,91611,91612,91614,91615,91616,91617,91618,90406,90407,90408,90409,90410,90411,90049,91201,91505,91502,90401,90251,90296,90293,91503,91507,91508,91510,91526,90402,91202,90250,91413,90032,90042,90061,90270,90041,91495,90245,91403,91606,90059,90249,91401,91501,91207,91206,91504,90261,90022,90247,91754,90201,90222,90091,90260,91208,91411,91803,90040,91030,91404,91407,91408,91409,91410,91470,91482,91496,91499,90506,90280,91605,90267,90266,90262,91436,91353,91031,91105,90248,91416,91426,91801,90272,91804,90504,90278,90202,91405,91123,91756,90223,90224,91802,91896,91899,91046,91714,91715,91352,91103,91716,91021,91316,91020,91755,90254,91102,91109,91110,91114,91115,91116,91117,91118,91121,91124,91125,91126,91129,91182,91184,91185,91188,91189,90220,91101,91406,91106,90640,91012,90747,91412,91214,91108,90746,91778,91402,91356,90239,90221,90240,91776,90723,90242,91043,90241,90503,90661,90662,90507,90508,90509,90510,91770,91775,91357,91104,90502,91331,91199,90660,90501,91334,91041,90277,91343,90749,91337,91003,91771,91772,91001,91385,91335,91333,90290,90805,90895,90745,91346,91395,90671,91107,91325,90706,90610,91040,90606,91733,91364,91371,91327,91328,91329,91345,90505,91780,91731,90264,91042,91341,91330,90707,90810,91365,91340,91007,91396,90710,91306,90807,90717,90712,90711,90714,90651,90652,91734,91735,91324,90650,91367,91305,91308,91309,91303,90601,91025,91394,90607,90608,90609,90670,91006,91066,91077,90602,91372,91024,91011,91732,90806,91392,90713,90748,90274,90744,91302,90702,90701,91344,90755,91746,90605,91023,90703"; String[] zipArray1 = zipCodes1.trim().split(","); Random zipIndex1 = new Random(); int randomIndex1 = zipIndex1.nextInt(395); System.out.println("Zip bad! New zip = "+zipArray1[randomIndex1]+""); driver.findElement(By.xpath("//android.widget.EditText[#index='0']")).sendKeys(zipArray1[randomIndex1]); Thread.sleep(750); driver.pressKey(new KeyEvent(AndroidKey.BACK)); Thread.sleep(1000); driver.findElement(saveLoc).click(); Thread.sleep(5750); if (driver.findElements(By.xpath("//*[#text='Check your zip and try again']")).isEmpty()) { System.out.println("Zip code change successful"); } else { continue start; } } but right after start on String zipCodes1 it gives me an error saying that: String cannot be resolved to a variable and zipCodes1 cannot be resolved to a variable why is this happening? is there a way to fix this?
Try doing this while(true){ String zipCodes1 = "90019,90036,90016,90005,90010,90018,90020,90004,90048,90035,90211,90006,90038,90008,90089,90062,90007,90028,90034,90212,90232,90231,90233,90057,90209,90213,90070,90029,90069,90015,90056,90037,90017,90067,90043,90046,90026,90071,90014,90230,90064,90099,90302,90189,90011,90030,90050,90051,90052,90053,90054,90055,90060,90072,90074,90075,90076,90078,90080,90081,90082,90083,90086,90087,90088,90093,90024,90009,90013,90068,90090,90079,90012,90210,90021,90025,90306,90307,90308,90309,90310,90312,90311,90095,90305,91608,90027,90084,90066,90301,90073,90094,90047,91522,91604,90039,90003,90044,91602,90031,91204,91523,90033,90295,90001,90045,90077,91521,90065,90096,90404,90292,90405,90303,90058,90294,90304,90291,91209,91221,91222,91224,91225,91226,91210,91205,90023,91203,91601,91393,91506,91423,90063,90002,90403,90255,91607,91603,91609,91610,91611,91612,91614,91615,91616,91617,91618,90406,90407,90408,90409,90410,90411,90049,91201,91505,91502,90401,90251,90296,90293,91503,91507,91508,91510,91526,90402,91202,90250,91413,90032,90042,90061,90270,90041,91495,90245,91403,91606,90059,90249,91401,91501,91207,91206,91504,90261,90022,90247,91754,90201,90222,90091,90260,91208,91411,91803,90040,91030,91404,91407,91408,91409,91410,91470,91482,91496,91499,90506,90280,91605,90267,90266,90262,91436,91353,91031,91105,90248,91416,91426,91801,90272,91804,90504,90278,90202,91405,91123,91756,90223,90224,91802,91896,91899,91046,91714,91715,91352,91103,91716,91021,91316,91020,91755,90254,91102,91109,91110,91114,91115,91116,91117,91118,91121,91124,91125,91126,91129,91182,91184,91185,91188,91189,90220,91101,91406,91106,90640,91012,90747,91412,91214,91108,90746,91778,91402,91356,90239,90221,90240,91776,90723,90242,91043,90241,90503,90661,90662,90507,90508,90509,90510,91770,91775,91357,91104,90502,91331,91199,90660,90501,91334,91041,90277,91343,90749,91337,91003,91771,91772,91001,91385,91335,91333,90290,90805,90895,90745,91346,91395,90671,91107,91325,90706,90610,91040,90606,91733,91364,91371,91327,91328,91329,91345,90505,91780,91731,90264,91042,91341,91330,90707,90810,91365,91340,91007,91396,90710,91306,90807,90717,90712,90711,90714,90651,90652,91734,91735,91324,90650,91367,91305,91308,91309,91303,90601,91025,91394,90607,90608,90609,90670,91006,91066,91077,90602,91372,91024,91011,91732,90806,91392,90713,90748,90274,90744,91302,90702,90701,91344,90755,91746,90605,91023,90703"; String[] zipArray1 = zipCodes1.trim().split(","); Random zipIndex1 = new Random(); int randomIndex1 = zipIndex1.nextInt(395); System.out.println("Zip bad! New zip = "+zipArray1[randomIndex1]+""); driver.findElement(By.xpath("//android.widget.EditText[#index='0']")).sendKeys(zipArray1[randomIndex1]); Thread.sleep(750); driver.pressKey(new KeyEvent(AndroidKey.BACK)); Thread.sleep(1000); driver.findElement(saveLoc).click(); Thread.sleep(5750); if (driver.findElements(By.xpath("//*[#text='Check your zip and try again']")).isEmpty()) { System.out.println("Zip code change successful"); break; } }
From JLS 14.7. Labeled Statements LabeledStatement: Identifier : Statement LabeledStatementNoShortIf: Identifier : StatementNoShortIf The Identifier is declared to be the label of the immediately contained Statement. Unlike C and C++, the Java programming language has no goto statement; identifier statement labels are used with break or continue statements (§14.15, §14.16) appearing anywhere within the labeled statement. The scope of a label of a labeled statement is the immediately contained Statement. So you can't use like below: start: String zipCodes1 = "..." One example you can use this with loops like answer by #Shrey Garg
for-loop doesn't work in android try-catch block
I am making database of my school's building and classroom with Realm. But, 'for-loop' in try-catch doesn't work: public void startCheckRealm() { // Writing DataBase with Realm try { Log.d("Realm", "Init"); InitializeAPI.init_BuildingRoom(getActivity().getApplicationContext()); Log.d("Realm", "Complete"); } catch(Exception e) { e.printStackTrace(); } // Trying to check the Database whether it is right or wrong try { Log.d("Realm Test", "2nd Try Catch"); Realm.init(getActivity().getApplicationContext()); Realm realm = Realm.getDefaultInstance(); RealmResults<BuildingList> buildingLists = realm.where(BuildingList.class).findAllSorted("buildingCode"); int totalNumber = 0; for(int i = 0; i < buildingLists.size(); i++) { Log.d("For", "index = " + i); RealmResults<RoomList> rooms = buildingLists.get(i).getRoomList().sort("roomCode"); String BuildingName = buildingLists.get(i).getBuildingName(); String BuildingCode = buildingLists.get(i).getBuildingCode(); for(int idx = 0; idx < rooms.size(); idx++) { totalNumber++; String RoomCode = rooms.get(idx).getRoomCode(); String RoomName = rooms.get(idx).getRoomName(); Log.d("Realm Test", "Number :: " + String.valueOf(totalNumber) + " BuildingCode :: " + BuildingCode + "\t\t BuildingName :: " + BuildingName + "\t\t RoomCode :: " + RoomCode + "\t\t RoomName :: " + RoomName); } } Log.d("Realm Test", "2nd Try Catch Complete + " + String.valueOf(totalNumber)); } catch(RealmException e) { e.printStackTrace(); } } In the first try-catch, the method, which does making database, is complete without Exception. I was curious whether this database is right or wrong. So, in 2nd try-catch, I was trying to check realm files with queries. The problem is "for-loop" doesn't work in 2nd try-catch. Below snippet is my logcat. D/Realm: Init I/System.out: bdList getLength :: 52 I/System.out: roomList getLength :: 2376 D/Realm: Complete D/Realm Test: 2nd Try Catch D/Realm Test: 2nd Try Catch Complete + 0 I want to check my realm data with Log but, doesn't work as you can see. If there is no problem, the logcat shows lots of my building and room lists and ends with "D/Realm Test: 2nd Try Catch Complete + 2376". Could you explain the reason why it doesn't work? I cannot understand the reason why it doesn't work even though there is no Exception.
While in your use-case this doesn't pose a problem, when you're iterating a RealmResults inside a transaction, the results are live in every version <= 0.88.3 and >= 3.0.0. So in that case, RealmResults<BuildingList> buildingLists = realm.where(BuildingList.class).findAllSorted("buildingCode"); for(int i = 0; i < buildingLists.size(); i++) { BuildingList buildingList = buildingLists.get(i); // <-- !!! will fail (it will skip every second item!) So you should use iterators instead (3.0.0+! on <= 0.88.3 you'd do reverse iteration) RealmResults<BuildingList> buildingLists = realm.where(BuildingList.class).findAllSorted("buildingCode"); for(BuildingList buildingList : buildingLists) { // <-- !!! The reason why this works is because iterators by default create a new snapshot collection (3.0.0+), and iterating by index on a snapshot also works OrderedRealmCollection<BuildingList> snapshot = buildingLists.createSnapshot(); for(int i = 0; i < ...
Simple: there is no exception thrown; and you only have your print statements inside the loop. Thus the one and only conclusion: at that point in time when your for loops are executed, the corresponding list is empty. Therefore the loop body is not entered; nothing gets printed. And that has nothing to do with the fact that this loop is within a try-catch block. That is all there is to this. So, the direct answer is: print the list size directly in front of the loop to avoid such surprises. (of course, the interesting part is to understand what happens to the list which seems to be non-empty earlier on - but in order to debug that, you would have to add more of your code).
Two inputs: 1.Haven't used realm but looks like the syntax for getting sorted entriesis a bit different Official documentation 2.If the above point is wrong than from your code it looks like buildingList size is zero. Have you tried checking the size? Let me know the results.
Try logging your catch block. Chances are the rest of the code including the loop didn't complete because your app was caught with the Exception.
You should debug buildingLists.size(); before for loop Log.d("Building List Size ", buildingLists.size()+""); In that case you can find the value of buildingLists.size();
Display text from throwable (Java)
So I am running the debugger and came across a variable 'e' which I think is error. But within that variable e is a variable "detailMessage". What is the code to get that string displayed? I would like something along these lines System.out.println("The error is " + e.detailMessage ); e is e MySQLSyntaxErrorException (id=67) Where e.detailMessage is the string. Thanks
The method is e.getMessage(); http://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#getMessage()
From the Java 7 API (http://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html) the method you want is getMessage(). System.out.println("The error is " + e.getMessage());
The correct way to show exceptions is by using a Logger, but for simplicity's sake, you should probably use e.printStackTrace(), this shows you the error as well as the stack where it occured. If you really want just the message (which in itself is not usually very useful) use getMessage() try{ // ... do something ... } catch (Exception e){ e.printStackTrace(); }
The method you are looking for is getMessage. In code: System.out.println("The error is " + e.getMessage());
No main method detected
The compiler keeps saying there is no main method but there is one: import java.util.HashMap; import java.util.Map; import java.util.Scanner; class StarWarsFinal { final static Map<String, String> firstNameMap = new HashMap<>(); static { firstNameMap.put("A", "Cho"); firstNameMap.put("B", "R2"); firstNameMap.put("C", "C-3po"); firstNameMap.put("D", "Yod"); firstNameMap.put("E", "Nas"); firstNameMap.put("F", "Slea"); firstNameMap.put("G", "Jan"); firstNameMap.put("H", "Zhur"); firstNameMap.put("I", "Boba"); firstNameMap.put("J", "Thre"); firstNameMap.put("K", "Bib"); firstNameMap.put("L", "Kit"); firstNameMap.put("M", "Kyp"); firstNameMap.put("N", "Gonk"); firstNameMap.put("O", "Zlung"); firstNameMap.put("P", "Adi"); firstNameMap.put("Q", "Nat"); firstNameMap.put("R", "Ru"); firstNameMap.put("S", "Cla"); firstNameMap.put("T", "Kir"); firstNameMap.put("U", "Obi"); firstNameMap.put("V", "Ken"); firstNameMap.put("W", "Ziro"); firstNameMap.put("X", "Zev"); firstNameMap.put("Y", "Tavion"); firstNameMap.put("Z", "Jar"); } final static Map<String, String> lastNameMap = new HashMap<>(); static { lastNameMap.put("A", "tzki"); lastNameMap.put("B", "hut"); lastNameMap.put("C", "der"); lastNameMap.put("D", "kzos"); lastNameMap.put("E", "vos"); lastNameMap.put("F", "vader"); lastNameMap.put("G", "thrawn"); lastNameMap.put("H", "mesk"); lastNameMap.put("I", "thuo"); lastNameMap.put("J", "skywalker"); lastNameMap.put("K", "D2"); lastNameMap.put("L", "maul"); lastNameMap.put("M", "sith"); lastNameMap.put("N", "muzzar"); lastNameMap.put("O", "jusik"); lastNameMap.put("P", "horn"); lastNameMap.put("Q", "phisto"); lastNameMap.put("R", "farlander"); lastNameMap.put("S", "dunhaussan"); lastNameMap.put("T", "jar"); lastNameMap.put("U", "binks"); lastNameMap.put("V", "lbis"); lastNameMap.put("W", "gnarzlo"); lastNameMap.put("X", "anakin"); lastNameMap.put("Y", "ackbur"); lastNameMap.put("Z", "axmis"); } final static Map<String, String> jobMap = new HashMap<>(); static{ jobMap.put("Jan","Clone"); jobMap.put("Feb","Bounty Hunter"); jobMap.put("Mar","Droid"); jobMap.put("Apr","Jedi Knight"); jobMap.put("May","Gungan"); jobMap.put("Jun","Gangster"); jobMap.put("Jul","commander"); jobMap.put("Aug","ewok"); jobMap.put("Sep","Queen"); jobMap.put("Oct","Empirer"); jobMap.put("Nov","Darth"); jobMap.put("Dec","captain"); } public static void main ( String[] args ) { String[] planet = null, rank = null, rebbelion = null, letter1 = null, letter2= null , Map , HashMap; Scanner input = new Scanner( System.in ); //scanner initilized planet = new String[11]; //Planet options planet[0] = "Alderaan"; planet[1] = "Bespin"; planet[2] = "Coruscant"; planet[3]= "Forest moon of Endor"; planet[4] = "Hoth"; planet[5] = "Kamino"; planet[6] = "Kashyyk"; planet[7] = "Mustafar"; planet[8] = "Yavin"; planet[9] = "DEATH STAR";//Planet options -END System.out.println("Welcome to the Star Wars name generator"); System.out.println("What is your first name?"); //Name Generation String firstName = input.nextLine(); String newFirst = firstNameMap.get(firstName.toUpperCase().substring(0,1)); //Name Generation (i want to take the first letter of there input and get the output from letter1 matching that # ie c = letter1 [2] a= letter1 [0]) System.out.println("What is your last name?"); //Name Generation String lastName = input.nextLine(); //Name Generation (i want to take the first letter of there input and get the output from letter2 matching that # ie c = letter2 [2] a= letter2 [0]) String newLast = lastNameMap.get (lastName.toUpperCase().substring(0,1)); System.out.println("What is your Birth month(first 3 letters)?"); //Name Generation String month = input.nextLine(); String job = jobMap.get(firstName.toUpperCase().substring(0,3)); System.out.println("If you had to choose 1)dark or 2)light side? please input the number"); //Selection of Dark or Light side int side = input.nextInt(); //Selection of Dark or Light side System.out.println("There are now several places you could live please choose one of the following by number:"); //Planet selections System.out.println("1) Alderaan 2) Bespin 3) Coruscant 4) Forest moon of Endor 5) Hoth "); //Planet selections System.out.println("6) Kamino 7) Kashyyk 8) Mustafar 9) Yavin 10)DEATHSTAR"); //Planet selections String location =input.nextLine(); if (side == 1) { System.out.println("You Have chosen to be part of the dark side!"); System.out.println("You "+ newFirst + newLast +" now fight for the dark side As a proud "+ job +"of the"+ location +"Good luck against your enemy's and may the force be with you"); } else { System.out.println("You are now part of the light side!"); System.out.println("You "+ newFirst + newLast +" now fight for the light side As a proud "+ job +"of the"+ location +"Good luck against your enemy's and may the force be with you"); } System.out.println("Thank you for doing the starwars name generator!"); } } I don't know why it won't read it, because it was working earlier. I'mm using NetBeans as IDE.
There is nothing wrong with the program. I did the following: [steve#newbox tmp]$ cat > StarWarsFinal.java <paste-program-from-question> [steve#newbox tmp]$ javac StarWarsFinal.java [steve#newbox tmp]$ java StarWarsFinal Welcome to the Star Wars name generator What is your first name? ^D Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1585) at StarWarsFinal.main(StarWarsFinal.java:112) [steve#newbox tmp]$ From this we must conclude that the problem you are experiencing is one of the following: You are not compiling it properly. You are not running it properly. There is something non-standard in the way that NetBeans is deciding that a class is runnable. (This is highly unlikely ... IMO) Maybe you are doing something else that you haven't mentioned ... For the record: It is NOT necessary for the class to be declared as public for it to be runnable, at least when you run it from the command line using the java command. It is not a Java compilation error for there to be no main method. It is a runtime error. A class only needs a main method if you are going to attempt to run it. The compiler has no way of knowing if you are going to do that, so it cannot complain about it. The "Hello World!" for the NetBeans IDE page runs you through the steps of compiling and running a simple program using NetBeans. Maybe this will give you some clues as to what you are doing wrong.