I am using Jgrasp, as that was the one I used a few years ago when I first started. Now that I am doing these again, I need a new one. I keep getting weird run time errors.

The programs work in my class examples, but when run on my JGrasp they do not run correctly.

I want to try a different compiler.

Does any one have any suggestions?

Thanks,
Andy

Also if you are a beginner why use a fancy IDE at all ? Try coding by your hand using an editor, that would be better in the long run. Though some people use IDEs from the very beginning, it only results in you not knowing the language environment in it's entirety.
For a java compiler, you can get the Java Development Kit on Sun's site.

Can you provide a link, once I get to the web site, there are two many options and I get lost, and not sure if I am downloading the correct thing/compiler?

Thanks again.

Looks good, All downloaded and running except...

How do I compile my code? I see the run tab, but nothing for compiling.

Thanks for your help.

I believe by default Eclipse is configured to automatically compile the java code when you run it.

@transplantedNYr

If you are just begining Java as it appears to be, just like verruckt I suggest you use a minimalistic IDE, With Eclipse just as you noticed now by asking about the compile button, you will get lost trying to figure your way around. Use a minimalistic IDE without autocomplete may be even just a text editor like Notepad, just as verruckt says you will understand the process what these IDEs do in the background and thus will make it easier for you to understand where to find what when you are actually working on large scale projects using an advanced IDE like Eclipse or Netbeans.

I personally prefer Eclipse for my projects but for beginners I always recommend lighter IDEs like JCreator LE (which is a freeware), BlueJ.

Knowing what happens in the background is always important because then you become free of your IDE and can change as needed, Using an IDE like Eclipse from the start will just force one mindset one way of thinking (on the way sources are organized, projects are created etc) that you will find switching over to other IDEs like Netbeans or IntelliJ very difficult.

I believe by default Eclipse is configured to automatically compile the java code when you run it.

Eclipse by default is configured to compile your code every time you save it. Unless you have manually disabled the "Build Automatically" option in the "Project" menu. If that is disabled you will have to manually go to Project -> "Build Project" to compile your sources.

I will try a few of these when I get home. (JCreator LE or BlueJ)

As for the JDK compiler. I have downloaded this but was unsure which file was the actual application to compile java code.

Jgrasp worked fine for Data Structures, i.e., Binary Trees, Lists, and arrays, but for my current assignments I need to do socket programming and write output files from my code, these are not working as expected with JGrasp.

Thanks again.

You need to set the PATH environment variable to include the installation path of Java. See this thread for the PATH setup. Once this is done you can run the javac command with file to be compiled
Ex : javac MyProgram.java this would generate a class file, which contains the bytecode. To run this class file you need to run the command 'java file'
Ex : java MyProgram (DO NOT put the .java extension here since it is the class file that you intend to run, class files have a .class extendsion)

And would this be from the command promt window? This would be very helpful. Then I could use a note pad to write my code.

I was able to run a couple of programs from the command promt window when the files were compiled in Jgrasp, just not anything beyond a simple data structure.

PS. I am at work now and will have to download/try all of these solutions when I get home. I will mark this solved then.

It does not seem to be working. I downloaded the software (Java SE Development Kit (JDK)) and set the path in Environmental Variables. There are a couple underneath my first path "C:\Program Files\Java\jdk1.6.0_11\bin;"
C:\Program Files\SSH Communications Security\SSH Secure Shell this was for a previous class where we ran c program through the schools shell. Then a Temp and Tmp file.

Then under that there is "System Variables". Do I need to do anything with these?

So I go to the folder from command prompt where my file is saved.
Then I enter "javac HelloWorldApp.java" I get the following error message...

'javac' is not recognized as an internal or external command, operable program or batch file

Then it says that I should enter the path , and then the "javac HelloWorldApp.java"

as

C:\Program Files\Java\jdk1.6.0_11\bin\javac HelloWorldApp.java
when I do this I get the following error message...

"C:\Program" is not recognized as an internal or external command, operable program or batch file.

I tried the BlueJ but I can not import packages or other API packages.

Does any one know what I am doing wrong?

Please help.

If you are going to call your "javac" compiler like this :-

C:\Program Files\Java\jdk1.6.0_11\bin\javac HelloWorldApp.java

You will need to put your "Program Files" in double quotes because of the space in "Program Files" (Courtesy MicroSoft for setting a lousy trend of accepting spaces in file and folder names).
Because of that space your command prompt thinks that your actual path to the executable is
"C:\Program" and the rest "Files\Java\jdk1.6.0_11\bin\javac HelloWorldApp.java" are just command line arguments to that program / executable.

Paste the entire content of your PATH(not the one belonging to System Variables Section) variable, Also I hope you opened a new console Window after saving the value of the PATH variable, cause this effect would not be repeated in an already open console.

Add your entire java path, the one that you mention - C:\Program Files\Java\jdk1.6.0_11\bin - in your PATH Environment variable. Then open a new command prompt window and type - javac. You should get an output similar to this :

Usage: javac <options> <source files>
where possible options include:
  -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

It would mean you have been successful in your attempt. Now you can proceed to compile files with the javac compiler.

Thanks the quotes worked as expected!

C:\"Program Files"\Java\jdk1.6.0_11\bin\javac HelloWorldApp.java

Now I can go have fun working on my code. Thanks again every one.

But, are you thinking of running it that way every time you need to compile/run a java file ? If you are expecting to have lots of fun with lots of java programs you should really think setting the PATH variable.

The Path Variable is already set as "C:\Program Files\Java\jdk1.6.0_11\bin;". This is what the Java Sun step by step insulation instructions stated should be the PATH.

What would be a better PATH Variable?

My work around is to have a notepad with
C:\"Program Files"\Java\jdk1.6.0_11\bin and then add the file to the end.

I am very open to making my life easier in the long run.

This article has been dead for over six months. Start a new discussion instead.