Re: Simple java test



Howard Brazee wrote:
What is the easiest way someone learning Java can run short little
test programs?

(I don't want to create JBuilder projects with libraries all over the
place for someone who is just wanting to learn)

This is a good question to ask and for a reason: do it the simply and straightforwards way. Forget IDEs (as you are indicating you want to do). If you work with the command line to begin with, you get a feel for what goes on 'under the hood', what is really happening.

Simplest possible way:
Ensure you have Java installed on your system, and the bin/ directory for Java is on your path.
open a command prompt. CD into a directory containing a java source file (e.g. HelloWorld.java).
Compile like so:

javac HelloWorld.java

This creates a HelloWorld.class file.
Run this like so:

java -cp . HelloWorld

(Note: there's no class at the end in above command!)
NB: this assumes your HelloWorld class doesn't have a package statement in it - i.e. the class is in the 'default' package.
lex
.



Relevant Pages

  • Re: A constructive debate: Eclipse or NetBeans?
    ... that Linux and command-line driven languages like OCaml are so much more ... That's because most people never learn to use a command line or a simple ... Trying to run other people's OpenGL-based Java demos from the web I find ... OpenGL). ...
    (comp.lang.java.softwaretools)
  • Process.waitFor() returns, but threads reading output/error streams are blocked on read
    ... threads to read in the out/err streams, ... i'll include the java source below, but the problem seems extremely specific ... passed in on the command line). ... process is hung if i terminate the process the command line tool connects to ...
    (comp.lang.java.programmer)
  • Re: Timed wait fails under WebStart in Java 1.6 prerelease?
    ... the java command line. ... that I show you the jnlp specs for the configuration which does not run: ... java.specification.vendor: <Sun Microsystems Inc.> ...
    (comp.lang.java.programmer)
  • Re: Regexes on the command line
    ... When the java command inside the script executes it reanalyzes the command string and since the single quotes are gone it misinterprets the special characters. ...
    (comp.lang.java.programmer)
  • Re: My shell cant find Java
    ... I downloaded java with netbeans from Sun ... >> Each time I type java I get an unknown command error. ... how you set environment variable depends on what shell you're using. ...
    (comp.lang.java.help)