Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • ragnoroker: BRAND NEW SERVER 6 HOURS OLD - RELIVE YOUR CHILDHOOD -[link]
      March 30, 2020, 09:17:02 PM
    • ragnoroker: BRAND NEW SERVER 6 HOURS OLD - RELIVE YOUR CHILDHOOD -[link]
      March 30, 2020, 09:16:51 PM
    • Themaxer: I need the starter pack please. Can someone pass me the link?
      March 28, 2020, 12:21:32 PM
    • Themaxer: Hi
      March 28, 2020, 12:19:26 PM
    • drubrkletern: whats happenin forum
      March 26, 2020, 10:14:36 PM
    • Lin: we're all old now
      March 24, 2020, 10:37:19 PM
    • wildskiller: wtf has happened to this forum
      March 24, 2020, 09:13:45 AM
    • rune-list: mistexps.com - #1 rsps with raids 1, raids 2, custom raids, new content, and more!
      March 21, 2020, 12:11:55 PM
    • ranger squad: I also miss u fags
      March 16, 2020, 04:50:33 AM
    • asshole_rule: miss u fags
      March 15, 2020, 10:08:18 AM
    • drubrkletern: damn... i wonder what the #1 CUSTOM RSPS of 2020 is ..
      March 14, 2020, 01:28:41 PM
    • rune-list: mistexps.com mistex rsps #1 custom & osrs rsps of 2020
      March 12, 2020, 11:42:49 AM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS of 2020 [link][link][link]
      March 11, 2020, 01:30:32 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS of 2020 [link][link][link]
      March 11, 2020, 01:30:28 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS of 2020 [link][link][link]
      March 11, 2020, 01:30:24 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS of 2020 [link][link][link]
      March 11, 2020, 01:30:20 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS of 2020 [link][link][link]
      March 11, 2020, 01:30:14 PM
    • SuperNativeZ: GALAXY #1 UNIQUE CUSTOM RSPS of 2020 galaxy-rsps.net/ galaxy-rsps.net/ galaxy-rsps.net/ galaxy-rsps.net/
      March 11, 2020, 01:29:44 PM
    • SnowRSPS: SnowRSPS.com SnowPS.org Snowscape.net  #1 CUSTOM RSPS - [link]
      March 09, 2020, 10:48:00 AM
    • SnowRSPS: SnowRSPS.com SnowPS.org Snowscape.net  #1 CUSTOM RSPS - [link]
      March 09, 2020, 10:47:57 AM

    Author Topic: Common Compiler Errors and Runtime Exceptions [ALL COMPILER RELATED ISSUES]  (Read 60685 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineDeathsChaos9

    • Skype: deathschaos9
    • Global Moderator
    • *****
    • *
    • Posts: 7,442
    • Thanks: +0/-0
      • View Profile
    Credits to Project Evolution, (Anthony), and myself for contributing to the thread.

    Table of Contents
    Compiler


    Common Java Exceptions   By (Anthony)




    Compiler Errors


    100 Errors

    This error happens to be a very common problem with beginners. This error is derived from a missing or having too many left or right brace brackets, { and }. 100 errors omit in private servers because that's the maximum the java compiler will output on default settings.

    public class Example {
       public int errors() {
          return 0;
       }
       
       public void moreErrors() {
       
       
       public static void main(String[] args) {
          System.out.println("This is an example of 100 errors!");
       }
    }
    This wont throw the legendary 100 errors because the code is to small, but the concept is the same. There is a missing bracket and because of this we get a silly error. Obviously, we need to add another bracket.
    Code: Java
    1. publicclass Example {
    2.         publicint errors(){
    3.                 return0;
    4.         }
    5.        
    6.         publicvoid moreErrors(){
    7.  
    8.         }
    9.        
    10.         publicstaticvoid main(String[] args){
    11.                 System.out.println("Correct number of brackets!");
    12.         }
    13. }



    Cannot Find Symbol

    Another common pitfall for novices. This error means a certain variable or method cannot be found or hasnt been defined. Usually this is the case when the variable or method is located in a different class. Take a look,
    Code: Java
    1. publicclass ClassOne {
    2.    privateint aVariable =2;
    3.    publicint getAVariable(){
    4.       return aVariable;
    5.    }
    6. }
    Code: Java
    1. publicclass ClassTwo {
    2.    publicvoid printTheAVariable(){
    3.       int variable = getAVariable();
    4.       System.out.println(variable);
    5.    }
    6. }
    They are both two different classes, and the objective is we want to print the aVariable located in the ClassOne class from the printTheAVariable() in the ClassTwo class. But we get an error, cannot find symbol. Whats the problem? Well, we didnt make a reference to the ClassOne class, so how do we expect the compiler to know what we are asking for? We simply instantiate the ClassOne class like so,
    Code: Java
    1. ClassOne classOne =new ClassOne();
    However we are not done. Now we need to reference our getAVariable() method. Here is what I mean,
    Code: Java
    1.    publicvoid printTheAVariable(){
    2.       int variable = classOne.getAVariable();
    3.       System.out.println(variable);
    4.    }
    This will call the getAVariable() method from the ClassOne class! If done correctly, it will print out the aVariable integer: 2.

    What if we wanted to call the aVariable in ClassOne instead of the getAVariable()? "I referenced correctly but it gives me a 'variable has private access' error." Well, thats going to be discussed in the next section. Also, this also partly applies to static variables/methods, read here

    Here is an exercise for you to work on,
    Code: Java
    1. publicclass PlayerLevel {
    2.    publicint playerLevel =126;
    3. }
    Code: Java
    1. publicclass PrintPlayerLevel {
    2.    publicvoid printPlayerLevel(){
    3.       int playerCbLevel = playerLevel;
    4.       sendMessage(playerCbLevel);
    5.    }
    6. }
    Figure out how to fix it.


    Variable has Private Access

    This is an error which applies to all methods/fields(variables) with the private modifier. For example,
    Code: Java
    1. privateint aVariable =2;
    These are methods/fields which arent called outside of the class it is within (however reflection is a different story iirc). Read up on these for more information,
    http://docs.oracle.com/javase/tutorial/java/javaOO/variables.html
    http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

    Looking back at the other example, what happens when we try and call the aVariable from the ClassOne class like so,
    Code: Java
    1. publicclass ClassOne {
    2.    privateint aVariable =2;
    3.    publicint getAVariable(){
    4.       return aVariable;
    5.    }
    6. }
    Code: Java
    1. publicclass ClassTwo {
    2.    ClassOne classOne =new ClassOne();
    3.    publicvoid printTheAVariable(){
    4.       int variable = classOne.aVariable;
    5.       System.out.println(variable);
    6.    }
    7. }
    We get: aVariable has private access in ClassOne. Why? Well, if you read the links I put up above, private modifiers mean methods/fields are only available within the class it is in. How can we fix this? Simply, you can take advantage of the Accessor pattern by making a 'getter' method like so,
    Code: Java
    1.    publicint getAVariable(){
    2.       return aVariable;
    3.    }
    Which was already used in the first place. Or you can make the aVariable field public. Here is the correct code,
    Code: Java
    1. publicclass ClassOne {
    2.    publicint aVariable =2;
    3.    publicint getAVariable(){
    4.       return aVariable;
    5.    }
    6. }
    Code: Java
    1. publicclass ClassTwo {
    2.    ClassOne classOne =new ClassOne();
    3.    publicvoid printTheAVariable(){
    4.       int variable = classOne.aVariable;
    5.       System.out.println(variable);
    6.    }
    7. }
    This is self explanatory however here is a short excercise. Make a simple getter method for a variable named playerLevel. Look above if you dont understand.


    ; Expected

    This is a pretty easy error. Like the error says, your missing a colon in the code. Colons are used to end expressions like so,
    Code: Java
    1. publicboolean expression =true;
    Colons are used a lot. "So why does my code give me a ; expected error?" Well, you obviously were missing a colon somewhere. Take a look at this example,
    Code: Java
    1. publicvoid doSomething(){
    2.    System.out.println("Doing something...")
    3. }
    Why was there a ; expected error? Look at the end of the println() method and figure it out, thats your exercise.


    ( or ) Expected

    This error occurs when there are dominating (too many) left or right brackets, ( or ). Another obvious fix, a simple way to fix it is to find where there are too many left brackets against right brackets. Look at this example,
    Code: Java
    1. if(aVariable1 == aVariable2 {
    2.    // do something here
    3. }
    As you can see a right bracket was missing. Here is the correction,
    Code: Java
    1. if(aVariable1 == aVariable2){
    2.    // do something here
    3. }
    This also applies to methods like so,
    Code: Java
    1. System.out.println(variable));
    That would give a ; expected, however the problem lies with the fact there is one too many right brackets.

    Your exercise for this section is trying to fix this if statement,
    Code: Java
    1. if((totalLevel +1)-(totalLevel +(0+0)){
    You dont have to focus on the variable or what this really does, the ovjective is to fix the brackets.


    Code Too Large

    This error is popping up more and more, and many people dont know why this happens. In a Jave method, its size cannot exceed 64KB. Why? Google it. What to do when this occurs? Well, you can split the one method into two parts. Say you have a method called parseIncomingPackets() (this is a RSPS reference) and it exceeded 64KB. A simple way to rid of this error would be to split it into two parts by creating a nother method such as parseIncomingPackets2(). Here is an example,
    Code: Java
    1. publicvoid parseIncomingPackets(){
    2.    // 64KB, compiler gives an error
    3. }
    Split up,
    Code: Java
    1. publicvoid parseIncomingPackets(){
    2.    // below 64KB, no error
    3. }
    4.  
    5. publicvoid parseIncomingPackets2(){
    6.    // below 64KB, no error
    7. }
    8.  
    Also, be noted you have to call the second method at one point probably like,
    Code: Java
    1. publicvoid parseIncomingPackets(){
    2.    // your code here
    3.    parseIncomingPackets2();
    4. }


    Duplicate Method

    This error occurs when a programmer attempts to put two of the same methods in a class like so,
    Code: Java
    1. class SomeClass {
    2.    publicvoid doSomething(){
    3.       // do something
    4.    }
    5.  
    6.    publicvoid doSomething(){
    7.       // do something
    8.    }
    9. }
    This would give a: doSomething is already defined in SomeClass error. An easy fix is to just remove the appropriate method. Its usually just removing an older method. However, there can be a workaround. Methods with the same name but different parameters are a different story. Read on,
    http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

    These are called overloading methods. Here is an example of overloaded methods,
    Code: Java
    1. class SomeClass {
    2.    publicvoid doSomething(Object object){
    3.       // do something
    4.    }
    5.  
    6.    publicvoid doSomething(){
    7.       // do something
    8.    }
    9. }
    As you can see, one of the doSomething() methods have a parameter which accepts an object. If you compile this class, you will not be given a duplicate method error. Your exercise is to create two different methods BOTH called getPlayer which one of them will accept a string called playerName and the other an integer called playerID.


    Duplicate Case Label

    This error occurs when a programmer is using a switch statement and attempts to compile when there are two of the same case labels. Here is an example of a duplicate case label,
    Code: Java
    1. switch(expression){
    2.    case1:
    3.       // do something
    4.    break;
    5.    case2:
    6.       // do something
    7.    break;
    8.    case2:
    9.       // do something
    10.    break;
    11. }
    Notice carefully and you will see two cases labelled with the number 2. This isnt allowed by the compiler so a fix would be like so,
    Code: Java
    1. switch(expression){
    2.    case1:
    3.       // do something
    4.    break;
    5.    case2:
    6.       // do something
    7.    break;
    8.    case3:
    9.       // do something
    10.    break;
    11. }
    You cant have multiple case labels. There is no exercise for this section.


    Missing Return Type

    A missing return type error indicates a method with no return type. A return type can be of an integer, boolean, char, string, etc. However this is not the case with constructors. Read up on constructors,
    http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html

    Say we have a method like so,
    Code: Java
    1. public doSomething(){
    2.    // do something here
    3. }
    Why is it the compiler returns a missing return type error? Its due to the fact doSomething has no return type, unless the class was named doSomething it wouldnt invoke an error becasue its a constructor. To fix such an error just place the return type you wish after the public modifier (or before the method name). Here is the fix,
    Code: Java
    1. publicvoid doSomething(){
    2.    // do something here
    3. }
    Remember that void isnt the only thing that can be used! You can use int, char, string, etc.

    Study this snippet,
    Code: Java
    1. class DoSomething {
    2.    public DoSomething(){
    3.       // code goes here
    4.    }
    5. }
    Does this give an error? Why or why doesnt it give an error?


    Missing Return Statement

    Missing return statements tie in with the section we went over above. Return types (other than void) must return a value.
    Code: Java
    1. publicint getInt(){
    2.    System.out.println("Called getInt!");
    3. }
    This simple method displays a message on the console. But there is a problem, a missing return statement error was thrown. Why? Like it says, we need the method to actually return something. All methods with a return type other than void requires a return statement. So to wrap this up, the fix would be,
    Code: Java
    1. publicint getInt(){
    2.    System.out.println("Called getInt!");
    3.    return anInteger;
    4. }
    anInteger represents a variable which is of an integer. This also doesnt make a difference to boolean or other return types. Your exercise is to make a method with a boolean return type which will return a boolean variable called aBoolean.


    Variable Already Defined

    A variable already defined error is similar to the duplicate method error. It means a variable is defined more than once. Take a look at this example which shows two local variables which would give the error,
    Code: Java
    1. privatevoid doSomething(){
    2.         int number =1;
    3.         int number = aVariable;
    4.         System.out.println(number);
    5. }
    As you should be able to notice, the number variable is defined twice in the same method. Which isnt allowed. Same thing goes for global variables.


    Non-static Variable Cannot be Referenced from a static context

    This error comes up when a programmer attempts to use a variable without a static keyword with a method that does. You can read more on static here,
    http://docs.oracle.com/javase/tutorial/java/javaOO/initial.html

    In the meantime, we have a class like so,
    Code: Java
    1. class StaticExample {
    2.    publicint aVariable =0;
    3.    publicstaticint getAVariable(){
    4.       return aVariable;
    5.    }
    6. }
    The problem lies with the aVariable. As you can see it has no static keyword. The fix would be to either make aVariable a static variable, or to make the getAVariable() method non-static. Very self-explanatory, a exercise shouldnt be needed.


    Class ... is public, should be declared in...

    This happens when a programmer tries to create a class that doesnt correspond to the name of the java file. Say for example we have a class named Client. Why would we get an error for having the following,
    Code: Java
    1. publicclass SomethingElse {
    2. }
    The reason behind this is because the class is called SomethingElse when it really should be called Client. See the relationship? Heres an exercise (and perhaps a tricky one for beginners). If I had a constructor that was named after the java file, but NOT named after the class declaration (which is SomethingElse), would it work?


    Unreported Exception

    An unreported exception error will be thrown if a snippet of code requires to be within a try/catch statement. Take a look at this example,
    Code: Java
    1.     publicvoid readFileInput(){
    2.        FileInputStream fis =newFileInputStream("file.txt");
    3.     }
    The problem with this code is it is necessary to have it closed in a try/catch block. To read more on those refer here,
    http://docs.oracle.com/javase/tutorial/essential/exceptions/handling.html

    In this case, a FileNotFoundException would be thrown if there happened to come an error. A fix would be to put all methods that require try/catch statements inside of one. Like so,
    Code: Java
    1.     publicvoid readFileInput(){
    2.         try{
    3.             FileInputStream fis =newFileInputStream("file.txt");
    4.         }catch(FileNotFoundException ex){
    5.             // Handle error
    6.         }
    7.     }
    You also must import the class that corresponds to the exception. In this case you would need to import the FileNotFoundException class.
    Code: Java
    1. importjava.io.FileNotFoundException;


    Illegal Start of Expression

    An illegal start of expression can come up even when code looks perfectly fine, some common problems with this error are listed below. Defining a static field in a method isnt allowed, if you were to do this,
    Code: Java
    1. publicvoid aMethod(){
    2.         staticint variable =5;
    3. }
    Another would be with unbalanced brace or regular brackets. Take a look at this if statement,
    Code: Java
    1. if(1+(11))==12)
    You can see here there is an extra bracket that isnt supposed to be there. This section will be updated more.


    ... cannot be applied to ...

    This error comes up when the programmer invokes a method with incorrect parameters. Say for example we have this class,
    Code: Java
    1. class SomeClass {
    2.    publicvoid sendMessage(String message, boolean isStaff){
    3.       // code here
    4.    }
    5.  
    6.    publicvoid run(){
    7.       sendMessage("This is a message");
    8.       // other codes here
    9.    }
    10. }
    This would give us an error that sendMessage(java.lang.String, boolean) in SomeClass cannot be applied to (java.lang.String). There is a simple explanation, due to the fact the sendMessage() method has two parameters; a string and a boolean, we only invoked the method with a string. To resolve this problem, we would also call sendMessage() with a string and boolean. This would be the fix,
    Code: Java
    1. class SomeClass {
    2.    publicvoid sendMessage(String message, boolean isStaff){
    3.       // code here
    4.    }
    5.  
    6.    publicvoid run(){
    7.       sendMessage("This is a message", true);// can be true or false
    8.       // other codes here
    9.    }
    10. }
    This also applies to whether its being called with a wrong type, too little or too many parameters. An exercise for you is, would having two different sendMessage() methods with different parameters fix the problem?


    Else without if

    An else without if error is pretty self explanatory, but I will go over it anyways. The result of such an error happens when using if statements or else/else if statements. Basically, a rule applies to else/else if statements - they need to have a beginning expression. What this means, is there needs to be an if statement before any else/else if statements. This is WRONG,
    Code: Java
    1. else{
    2.    // shit here
    3. }
    This is correct,
    Code: Java
    1. if(expression){
    2.    // shit here
    3. }else{
    4.    // shit here
    5. }
    This is WRONG,
    Code: Java
    1. elseif(expression){
    2.    // shit here
    3. }else{
    4.    // shit here
    5. }
    This is correct,
    Code: Java
    1. if(expression){
    2.    // shit here
    3. }elseif(expression){
    4.    // shit here
    5. }else{
    6.    // shit here
    7. }
    Hopefully you get the point.

    « Last Edit: July 23, 2011, 09:31:09 AM by Tom_BETA »
    Peace isn't merely the absence of conflict, but the presence of justice.
    Runescape Gambling

    OfflineDeathsChaos9

    • Skype: deathschaos9
    • Global Moderator
    • *****
    • *
    • Posts: 7,442
    • Thanks: +0/-0
      • View Profile
    Common Compiler Errors & Java Exceptions
    « Reply #1 on: May 28, 2010, 05:40:41 PM »

    Reached end of file while parsing
    This error is thrown when you are missing a bracket near the end of your class.
    Code: Java
    1. publicclass Example {
    2.         publicstaticvoid main(String args[]){
    3.                 //Do Stuff
    4.         }
    5.  
    As you can see in this case, the class was left unclosed. It should be written as
    Code: Java
    1. publicclass Example {
    2.         publicstaticvoid main(String args[]){
    3.                 //Do Stuff
    4.         }
    5. }
    Its a very simple fix, unlike finding your missing bracket in 100 errors, you can simply go to the end of your class and have look around :)


    package ... does not exist
    Thrown when importing a nonexistant package.

    Code: Java
    1. importjava.io.inPutStream;
    2.  

    The package you import has to exist. Naturally, its case sensitive.

    Code: Java
    1. importjava.io.InputStream;
    2.  

    If your importing from your own source files, the package is the folders leading up to the class.

    Code: Java
    1. importcom.rs2.server.Server;// Imports Server class
    For more info: http://docs.oracle.com/javase/tutorial/java/package/usepkgs.html


    Orphaned Case
    An orphaned case is a case that is lying outside of a switch statement
    Code: Java
    1. switch(example){
    2.         case1:
    3.                 //Stuff
    4.         break;
    5.  
    6.         case2:
    7.                 //Stuff
    8.         break;
    9. }
    10.         case3:
    11.                 //Orphaned Case
    12.         break;
    13.  
    As you can see, the case was declared after the statement was closed.
    This is a common error and quite easy to fix, simply A.) Move the case inside a switch statement, or B.) Surround the case with a switch statement
    Code: Java
    1. switch(example){
    2.         case1:
    3.                 //Stuff
    4.         break;
    5.  
    6.         case2:
    7.                 //Stuff
    8.         break;
    9.  
    10.         case3:
    11.                 //Stuff
    12.         break;
    13. }


    'try' without 'catch' or 'finally'
    You wrote try {, but forgot a catch or finally.
    Code: Java
    1.         publicstaticvoid main(String[] args){
    2.                 try{
    3.                         new java.net.ServerSocket(43594, 1, null);//Wrong
    4.                 }
    5.         }
    This would throw the error. Its pretty easy to fix, you just need to add catch with the appropriate exception (see Java Exceptions)
    Code: Java
    1.         publicstaticvoid main(String[] args){
    2.                 try{
    3.                         new java.net.ServerSocket(43594, 1, null);
    4.                 }catch(IOException e){
    5.                         e.printStackTrace();
    6.                 }
    7.         }

    Alternatively, you can add a throw to the method.
    Code: Java
    1.         publicstaticvoid main(String[] args)throwsIOException{
    2.                         new java.net.ServerSocket(43594, 1, null);
    3.         }


    Unreachable Statement
    I thought I added that error, guess not. Anyway, an unreachable statement is a statement that comes after a break or return.

    Here's an example of an unreachable statement.
    Code: Java
    1. class Example {
    2.     publicstaticvoid main(String args[]){
    3.         if(args[0].equals("example")){
    4.             System.out.println("This is an example");
    5.             return;
    6.             System.out.println("This is an unreachable statement");
    7.         }
    8.     }
    9. }

    An acceptable alternative would be something like.

    Code: Java
    1. class Example {
    2.     publicstaticvoid main(String args[]){
    3.         if(args[0].equals("example")){
    4.             System.out.println("This is an example");
    5.             return;
    6.         }
    7.         System.out.println("This is an unreachable statement");
    8.     }
    9. }

    Invalid Escape Character
    This error is thrown when you improperly use the backslash (\) in a string.
    Code: Java
    1. System.out.println("Hello \ World");
    To fix, you will have to either remove the backslash or add a valid escape character.

    Code: Java
    1. System.out.println("Hello \\ World");

    Valid Escape Characters:
    \b - Backspace
    \t - Tab
    \n - New line
    \f -  :confused:
    \r - Return (enter)
    \" - Quote (")
    \' - Singe quote (')
    \\ - Backslash

    Note: ...
    Code: [Select]
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -deprecation for details.

    This is just a warning, not an error. In this example you could add -deprecation to your compiler to show where deprecated APIs are used.

    Code: [Select]
    Javac -deprecation *.javaHere is a list of Javac options:
    •   -g                         Generate all debugging info
    •   -g:none                    Generate no debugging info
    •   -g:{lines,vars,source}     Generate only some debugging info
    •   -nowarn                    Generate no warnings
    •   -verbose                   Output messages about what the compiler is doing
    •   -deprecation               Output source locations where deprecated APIs are used
    •   -classpath <path>          Specify where to find user class files and annotation processors
    •   -cp <path>                 Specify where to find user class files and annotation processors
    •   -sourcepath <path>         Specify where to find input source files
    •   -bootclasspath <path>      Override location of bootstrap class files
    •   -extdirs <dirs>            Override location of installed extensions
    •   -endorseddirs <dirs>       Override location of endorsed standards path
    •   -proc:{none,only}          Control whether annotation processing and/or compilation is done.
    •   -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
    •   -processorpath <path>      Specify where to find annotation processors
    •   -d <directory>             Specify where to place generated class files
    •   -s <directory>             Specify where to place generated source files
    •   -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
    •   -encoding <encoding>       Specify character encoding used by source files
    •   -source <release>          Provide source compatibility with specified release
    •   -target <release>          Generate class files for specific VM version
    •   -version                   Version information
    •   -help                      Print a synopsis of standard options
    •   -Akey[=value]              Options to pass to annotation processors
    •   -X                         Print a synopsis of nonstandard options
    •   -J<flag>                   Pass <flag> directly to the runtime system




    Common Java Exceptions   By (Anthony)


    java.lang
    ClassCastException - Occurs when you try to cast an object to a class which is not it's subclass, sub interface, or class.
    Example:
    Code: Java
    1. RsObject rsObject =new RsObject();
    2. WowObject wowObject =(WowObject) rsObject;// This line would throw a ClassCastException as rsObject is not a WowObject.
    ArrayIndexOutOfBoundsException - Thrown when you try to access an index on an array which doesn't exist.
    Example:
    Code: Java
    1. Object[] array =newObject[200];
    2. Object obj = array[200];// Would throw an ArrayIndexOutOfBoundsException as the array indices start at 0 meaning max is 199.
    NullPointerException - Thrown when you try to use an object reference who's value is null.
    Example:
    Code: Java
    1. Object object =null;
    2. object.notify();// Would throw NullPointerException as the object to which object points is null.


    java.util
    ConcurrentModificationException - Thrown when multiple threads try to read/modify an object at the same time. Multiple threads can read at the same time but multiple threads can't write at the same time, or read and write at the same time.


    java.io
    FileNotFoundException - Gets thrown when you try to load a file that doesn't exist.
    IOException - Thrown when an errors occurs with Input/Output, this may be a reading or writing to a stream or channel problem.
    NotSerializableException - Thrown when you try to serialize an object that doesn't implement Serializable.

    Well that's all I can think of right now, if there are any you would like me to add just request it and I'd be happy to.
    « Last Edit: December 18, 2010, 07:08:13 PM by deathschaos9 »
    Peace isn't merely the absence of conflict, but the presence of justice.

    OfflineJc22493

    • Rock climber
    • Member
    • ****
    • *
    • Posts: 12,372
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #2 on: May 28, 2010, 08:31:38 PM »
    This is Anthony's, right?

    OfflineThe Soul

    • MoparScape Vet
    • Member
    • ****
    • *
    • Posts: 5,354
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #3 on: May 28, 2010, 08:51:49 PM »
    <Jc22493> ts how was sex
    <Lin> he was okay

    Offline(Anthony)

    • Member
    • ****
    • Posts: 1,182
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #4 on: May 29, 2010, 01:51:21 AM »
    class OneHunderedError {
       public static void main(String[] args) {
          System.out.println("This is an example of 100 errors!");
    }
    No, that's an example of an idiot not putting a bracket there. That would not throw 100 errors as there isn't any code being fudgeed up and in the wrong scope in the class it would probably just say someone along the lines of "Reached the end of the file while parsing".

    OfflineDeathsChaos9

    • Skype: deathschaos9
    • Global Moderator
    • *****
    • *
    • Posts: 7,442
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #5 on: May 29, 2010, 10:15:38 AM »
    class OneHunderedError {
       public static void main(String[] args) {
          System.out.println("This is an example of 100 errors!");
    }
    No, that's an example of an idiot not putting a bracket there. That would not throw 100 errors as there isn't any code being fudgeed up and in the wrong scope in the class it would probably just say someone along the lines of "Reached the end of the file while parsing".
    Yea I noticed, better now?
    Peace isn't merely the absence of conflict, but the presence of justice.

    Offlinedeviltw2nz

    • Member
    • **
    • Posts: 9
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #6 on: May 29, 2010, 12:45:17 PM »
    Can you help me? idk if its good that i'm writing here but i got problem with illegal start of expression... can anyone fix it for me please?

    Code: [Select]
    public void debug(String text) {
    if (debug);
    sM(text);
    }
    public void declineTrade() {
    if (disconnected) {
    declineTrade(true);
    }
    declineTrade(true);
    }

    Offline(Anthony)

    • Member
    • ****
    • Posts: 1,182
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #7 on: May 29, 2010, 02:32:26 PM »
    class OneHunderedError {
       public static void main(String[] args) {
          System.out.println("This is an example of 100 errors!");
    }
    No, that's an example of an idiot not putting a bracket there. That would not throw 100 errors as there isn't any code being fudgeed up and in the wrong scope in the class it would probably just say someone along the lines of "Reached the end of the file while parsing".
    Yea I noticed, better now?
    Yeah that would throw an illegal start of expression and then a reached end of file while parsing. There aren't 100 errors to be thrown so it obviously won't throw 100 errors. But you get the general idea.

    OfflineThe Soul

    • MoparScape Vet
    • Member
    • ****
    • *
    • Posts: 5,354
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #8 on: May 29, 2010, 03:09:36 PM »
    Can you help me? idk if its good that i'm writing here but i got problem with illegal start of expression... can anyone fix it for me please?

    Code: [Select]
    public void debug(String text) {
    if (debug);
    sM(text);
    }
    public void declineTrade() {
    if (disconnected) {
    declineTrade(true);
    }
    declineTrade(true);
    }

    Where you're checking the first condition, if 'debug' is true or not, you have to open and close the statement.
    <Jc22493> ts how was sex
    <Lin> he was okay

    Offline(Anthony)

    • Member
    • ****
    • Posts: 1,182
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #9 on: May 30, 2010, 04:32:54 AM »
    Can you help me? idk if its good that i'm writing here but i got problem with illegal start of expression... can anyone fix it for me please?

    Code: [Select]
    public void debug(String text) {
    if (debug);
    sM(text);
    }
    public void declineTrade() {
    if (disconnected) {
    declineTrade(true);
    }
    declineTrade(true);
    }

    Where you're checking the first condition, if 'debug' is true or not, you have to open and close the statement.
    Actually right now it is perfectly legal it just has no body. His compiling issue is that his code more than likely resides within another methods body.

    OfflineThe Soul

    • MoparScape Vet
    • Member
    • ****
    • *
    • Posts: 5,354
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #10 on: May 30, 2010, 08:14:48 AM »
    Can you help me? idk if its good that i'm writing here but i got problem with illegal start of expression... can anyone fix it for me please?

    Code: [Select]
    public void debug(String text) {
    if (debug);
    sM(text);
    }
    public void declineTrade() {
    if (disconnected) {
    declineTrade(true);
    }
    declineTrade(true);
    }

    Where you're checking the first condition, if 'debug' is true or not, you have to open and close the statement.
    Actually right now it is perfectly legal it just has no body. His compiling issue is that his code more than likely resides within another methods body.

    I wasn't talking about resolving his error but rather telling him to fix that as it's pointless to have a condition if you're not going to use it.
    <Jc22493> ts how was sex
    <Lin> he was okay

    Offlinelil.astar

    • Member
    • ***
    • Posts: 201
    • Thanks: +0/-0
      • View Profile
      • Prince Jefferson
    Re: Common Compiler Errors
    « Reply #11 on: June 04, 2010, 03:58:44 AM »
    Mine Says Cannot Create Virtual Machine. -d, Does anyone know what i can do?

    Offlineultraking x2

    • Member
    • **
    • Posts: 69
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #12 on: June 18, 2010, 06:08:13 AM »
    Can you plz help me with this error, i downloaded tokkulscape 508 yesterday, but if i run the server, this happen:

    Quote
    Exception in thread "main" java.lang.NoClassDefFoundError: Bulby/Server
    Caused by: java.lang.ClassNotFoundException: Bulby.Server
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: Bulby/Server.  Program will exit.
    Press any key to continue. . .
    Plz, help me, this is my first private server, keep it very simple plz

    Offlineit0ken1

    • Member
    • **
    • Posts: 20
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #13 on: June 18, 2010, 06:14:10 AM »
    Doesn't seem to find the main class of the server.
    Either the archive's broken or you deleted an important file.

    Offlineultraking x2

    • Member
    • **
    • Posts: 69
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #14 on: June 18, 2010, 06:56:33 AM »
    I didn't deleted any file. How can i fix this?

    Offlineit0ken1

    • Member
    • **
    • Posts: 20
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #15 on: June 18, 2010, 06:57:50 AM »
    I didn't deleted any file. How can i fix this?
    Maybe the archive is broken. Try re-downloading the server.
    If that doesn't work, I'd go with a whole new source.

    Offlineultraking x2

    • Member
    • **
    • Posts: 69
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #16 on: June 18, 2010, 07:02:51 AM »
    re-downloading now, i hope this works...

     :confused: It still doen't work! Again the same error! :(

    Quote
    Het systeem kan het opgegeven pad niet vinden.
    Exception in thread "main" java.lang.NoClassDefFoundError: Bulby/Server
    Caused by: java.lang.ClassNotFoundException: Bulby.Server
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: Bulby/Server.  Program will exit.
    Press any key to continue. . .

    Any1 can help me or does any1 has a link to a tutorial for this error?
    « Last Edit: June 18, 2010, 07:16:58 AM by ultraking x2 »

    OfflineDeathsChaos9

    • Skype: deathschaos9
    • Global Moderator
    • *****
    • *
    • Posts: 7,442
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #17 on: June 18, 2010, 12:31:09 PM »
    Server class isn't in the Bulby package. Check the code in the batch file and make sure that the path is set to were Server class actually is.
    Peace isn't merely the absence of conflict, but the presence of justice.

    Offline(Anthony)

    • Member
    • ****
    • Posts: 1,182
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #18 on: June 18, 2010, 02:12:15 PM »
    Server class isn't in the Bulby package. Check the code in the batch file and make sure that the path is set to were Server class actually is.
    It's also possible that he doesn't have the server files in the classpath.

    OfflineSi Force

    • The beekeeper
    • Member
    • ****
    • *
    • Posts: 5,328
    • Thanks: +0/-0
      • View Profile
    Re: Common Compiler Errors
    « Reply #19 on: June 18, 2010, 02:54:26 PM »
    Do you plan on adding on to your thread and updating it? I don't think all errors are covered.
    There is a house in New Orleans

    Check out the Official Moparscape Server! Being developed by Sinisoul and Davidi2

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal