Results 1 to 2 of 2
  1. #1
    mnhad3 is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Default Java Compiler Program

    Hi all,
    Can someone please point out the cause of my problem & how to fix it:
    This is the program that I am trying to run:
    Java Code:
    import java.io.*;
    import javax.tools.*;
    
    public class FirstCompile {
    	public static void main(String args[]) throws IOException {
    		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    		int results = compiler.run(null, null, null, "HelloWorld.java");
    		System.out.println("Success: " + (results == 0));
    	}
    }
    The HelloWorld.java file is in the same folder with this program & when I try to run the program, I get this error message:
    Java Code:
    Exception in thread "main" java.lang.NullPointerException
            at FirstCompile.main(FirstCompile.java:7)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,526
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by mnhad3 View Post
    Hi all,
    Can someone please point out the cause of my problem & how to fix it:
    This is the program that I am trying to run:
    Java Code:
    import java.io.*;
    import javax.tools.*;
    
    public class FirstCompile {
    	public static void main(String args[]) throws IOException {
    		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    		int results = compiler.run(null, null, null, "HelloWorld.java");
    		System.out.println("Success: " + (results == 0));
    	}
    }
    The HelloWorld.java file is in the same folder with this program & when I try to run the program, I get this error message:
    Java Code:
    Exception in thread "main" java.lang.NullPointerException
            at FirstCompile.main(FirstCompile.java:7)
    That's not how you can run the Java compiler. Go to the top page of the API documentation; you'll see a block with each and every technology there. The second block from the left in the top row points you to the API documentation for the compiler; read it.

    kind regards,

    Jos

Similar Threads

  1. java compiler error
    By arshesander in forum New To Java
    Replies: 7
    Last Post: 02-21-2010, 04:18 AM
  2. How to Set up my Java Compiler
    By Galore in forum New To Java
    Replies: 4
    Last Post: 01-17-2010, 05:57 PM
  3. Create new java compiler
    By gino62389 in forum Advanced Java
    Replies: 2
    Last Post: 11-04-2009, 03:57 PM
  4. The best compiler for java
    By baltimore in forum New To Java
    Replies: 2
    Last Post: 08-06-2007, 05:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •