I need a good java compiler

Reply

Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

I need a good java compiler

 
0
  #1
Feb 15th, 2005
Hi all, does anyone know of a good compiler I can download for java? It would be nice if it was an IDE but it does not have to be. I currently have the j2sdk-1_4 compiler http://java.sun.com/j2se/1.4.1/download.html and it does not seem to work that well. Also I know that this is really easy, but hey I can't compile anything I make, what is wrong with this code?
  1. public class BuckleShoe
  2. {
  3. public static void main(String args)
  4. {
  5. EasyReader console = new EasyReader();
  6. private int choice;
  7.  
  8. do
  9. {
  10. System.out.print("Enter a number 1-10 (or 0 to quit):");
  11. int choice = console.readInt ();
  12.  
  13. switch (choice)
  14. {
  15. case 0:
  16. System.out.println("Bye");
  17. break;
  18.  
  19. case 1:
  20. case 2:
  21. System.out.println("Buckle your shoe");
  22. break;
  23.  
  24. case 3:
  25. case 4:
  26. System.out.println("Shut the door");
  27. break;
  28.  
  29. case 5:
  30. case 6:
  31. System.out.println("Pick up sticks");
  32. break;
  33.  
  34. case 7:
  35. case 8:
  36. System.out.println("lay them straight");
  37. break;
  38.  
  39. case 9:
  40. case 10:
  41. System.out.println("A big fat hen");
  42. break;
  43.  
  44. default:
  45. System.out.println("invalid entry");
  46. break;
  47. }
  48. } while (choice != 0);
  49. }
  50. }
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: I need a good java compiler

 
0
  #2
Feb 15th, 2005
My guess is that your school uses some new packaged classes because they are too lazy to create a one line statement that reads input. EasyReader is not a java class, that is, if you haven't downloaded that add on..

use this:

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int x = br.readLine();
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: I need a good java compiler

 
0
  #3
Feb 16th, 2005
Originally Posted by server_crash
My guess is that your school uses some new packaged classes because they are too lazy to create a one line statement that reads input.
Your guess is right, ( I probably should have said that) but I can not even compile extremely simple programs such as:
  1. public class HelloWorld
  2. {
  3. public static void main(String[] args)
  4. {
  5. System.out.println("Hello, World");
  6. }
  7. }

I get an error message that says:

Empty.java [1:1] class HelloWorld is public, should be declared in a file named HelloWorld.java
public class HelloWorld
^
1 error
Errors compiling Empty.

I don't understand, am I supposed to save in some sort of special file/format before compiling?
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: I need a good java compiler

 
0
  #4
Feb 16th, 2005
The filename should have the same name as the class:

public class X

so the filename should be:

X.java

Is your filename HelloWorld.java ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: I need a good java compiler

 
0
  #5
Feb 16th, 2005
Originally Posted by server_crash
The filename should have the same name as the class:

public class X

so the filename should be:

X.java

Is your filename HelloWorld.java ?
The file name is the same ( HelloWorld.java ), but here is another error message I get when i try to create the program,
  1. java.lang.NoClassDefFoundError: Mystuff/Empty
  2. Exception in thread "main"
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: I need a good java compiler

 
0
  #6
Feb 16th, 2005
Ohh I see what it is now, it's your classpath..Have you set it yet?


If you haven't set it to point directly to the tools.jar file

If you have, post it, and I will take a look at it.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 42
Reputation: the b is an unknown quantity at this point 
Solved Threads: 0
the b the b is offline Offline
Light Poster

Re: I need a good java compiler

 
0
  #7
Feb 17th, 2005
Actually I haven't :o how would I start to do this? I have Netbeans IDE version 3.6 as my compiler, and I am running it on windoze xp home.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,145
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: I need a good java compiler

 
0
  #8
Feb 17th, 2005
The Sun compiler is the ONLY official one for the language.
There are others that are certified to be correct but the Sun package (which you claim doesn't work...) is the standard.

Anything that doesn't compile with that should not compile with anything.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: I need a good java compiler

 
0
  #9
Feb 17th, 2005
Sorry, I've never really worked with netbeans, so I don't know anything about setting the classpath on that...Maybe it's the same principle though:

try this:

GOTO: Start -->(right click on)My computer--> properties -->advanced

--environment variables

you should have one that says classpath and path:

set the path variable to the path that points to the bin folder located in your jdk folder

set the classpath variable to the path that points to the tools.jar file located in your jdk folder

Again, not sure if this will work. I don't use netbeans.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,145
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: I need a good java compiler

 
0
  #10
Feb 18th, 2005
If you don't even know how to use your classpath you shouldn't be using an IDE at all.
For an IDE, you normally set the included libraries for a project in the project options.
RTFM about how to do that.
As to Netbeans, scrap that piece of junk.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC