title: Java method help
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2392028/static-method-in-java">Static method in java</a>  </p>
  </blockquote>
  
  
  
  <p>Ok, so I'm working on a project for a class I'm taking.. simple music library. Now I'm having some issues, the main issue is I'm getting "non-static method cannot be referenced from a static context" </p>
  
  <p>Here is a function I have </p>
  
  <pre><code>public void addSong() {
      Scanner scan = new Scanner(System.in);
      Song temp = new Song();
      int index = countFileLines(Main.databaseFile);
      index = index + 2;
      temp.index = index;
      System.out.print("Enter the artist name: ");
      temp.artist.append(scan.next());
  }
  </code></pre>
  
  <p>Now thats in a class file called LibraryFunctions. So I can access it with LibraryFunctions.addSong(); </p>
  
  <p>Now I'm trying to run this in my main java file and its giving me the error, I know why the error is happening, but what do I do about it? If I make addSong() a static function then it throws errors at me with the Song temp = new Song() being static. Kind of ironic. </p>
  
  <p>Much help is appreciated on this! </p>