Help: HelloWorld

I

Ivan

I'm trying to teach myself Java. I downloaded AND installed j2se, and
set the JAVA_HOME path. I installed gcj as a compiler, and it seems to
work just fine..

But that's when all my problems start.

I end up with a file called HelloWorld.o

Perhaps I'm not using the compiler correctly..

But when I type java HelloWorld.o I come up with error Exception in
thread "main" java.lang.NoClassDefFoundError: HelloWorld/o

Let me know what am doing wrong plz..

Using Linux SuSE, and below is a copy of my HelloWorld script, which
I've adequately named HelloWorld.java

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
 
T

Todd.Bjorlo

You have to use the javac compiler, which comes with j2se. gcj afaik
is a GNU Java Compiler. java and javac are parts of the j2se package.
You have to type "javac HelloWorld.java", which should create
"HelloWorld.class" which you can then run with the java command by
typing "java HelloWorld"
 
R

Rhino

Ivan said:
I'm trying to teach myself Java. I downloaded AND installed j2se, and
set the JAVA_HOME path. I installed gcj as a compiler, and it seems to
work just fine..

But that's when all my problems start.

I end up with a file called HelloWorld.o

Perhaps I'm not using the compiler correctly..

But when I type java HelloWorld.o I come up with error Exception in
thread "main" java.lang.NoClassDefFoundError: HelloWorld/o

Let me know what am doing wrong plz..

Using Linux SuSE, and below is a copy of my HelloWorld script, which
I've adequately named HelloWorld.java

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}

Please do not multipost. You posted this same question at
comp.lang.java.help, which is the appropriate place for newbie questions.
Posting it here too just wastes your time and the time of people on this
forum who don't realize you've already been answered elsewhere.
 
J

Jon Martin Solaas

Ivan said:
I'm trying to teach myself Java. I downloaded AND installed j2se, and
set the JAVA_HOME path. I installed gcj as a compiler, and it seems to
work just fine..

But that's when all my problems start.

I end up with a file called HelloWorld.o

Perhaps I'm not using the compiler correctly..

But when I type java HelloWorld.o I come up with error Exception in
thread "main" java.lang.NoClassDefFoundError: HelloWorld/o

Let me know what am doing wrong plz..

Using Linux SuSE, and below is a copy of my HelloWorld script, which
I've adequately named HelloWorld.java

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}

You must decide which java you want to use. Compiling with gnu java and
running with sun java won't work.

Use `javac` from sun to compile and `java` to run your program, or use
`gcj` to compile the program into a native executable which you run like
any other native program. gcj compiles and links java-programs just like
gcc compiles and links c/c++ programs; `gcj HelloWorld.java -o
HelloWorld` and `chmod 700 HelloWorld; ./HelloWorld` should do it ...

If you go for the sun-variant, make sure you get the sdk and not jre, as
the latter has no compiler. It's also nice to have an IDE where you
edit, compile and debug yor application, like NetBeans, Eclipse or
JDeveloper (or any other IDE for that sake ...)
 
Z

zero

John Bailo said:
Why don't you download a nice complete (java compatible) IDE like
Eclipse...then you'd really learn something:

Because using an IDE when you're just starting to learn is a bad idea, for
a dozen reasons that have been discussed in this group several times.

It may even lead to top-posting.
 
M

Monique Y. Mudama

Why don't you download a nice complete (java compatible) IDE like
Eclipse...then you'd really learn something:

http://www.eclipse.org

If I had tried to use Eclipse instead of a simple text editor to write
my first (several hundred) Java program(s), I think I would have
fainted.

I love Eclipse now, but it's a bit much when you're just trying to
figure out how to tie your shoes in Java.
 
I

Ivan

Hi..

I've installed eclipse on my machine and after writing the hello world
script I realized that perhaps it might be a better idea to lear nthe
basics of java and then move on to an IDE..

It can be a bit confusing having to learn to use two things at the same
time..

Not only that, but I didn't have to write

public static void main....

as eclipse did it for me..

I'm sure that knowledge will come in handy in the future..
 
J

James McGill

I love Eclipse now, but it's a bit much when you're just trying to
figure out how to tie your shoes in Java.

It's difficult to appreciate the value of a tool that solves a problem
until you have experienced that problem. That's true for the IDE, and
it's also true of the motivations behind many things programming that
have an associated learning curve.

On the other hand, I fail to see how Eclipse in particular, gets in the
way of anything. Probably because I'm much too experienced and too
comfortable with it to even try to see through a beginner's eyes.
 
J

John Bailo

Ivan said:
Hi..

I've installed eclipse on my machine and after writing the hello world
script I realized that perhaps it might be a better idea to lear nthe
basics of java and then move on to an IDE..

You're going to be using both eventually -- so why not learn the right way?
It can be a bit confusing having to learn to use two things at the same
time..

Which is easier?

Entering your code, and pressing a button that says Compile/Run or dealing
with a million switches, paths, classpaths just to point things to where
you can make it compile?

Not only that, but I didn't have to write

public static void main....

as eclipse did it for me..

Coast.

It's the only way...
 
I

Ivan

hhmm..

I want to learn to code in Java, not to use a program that will code
for me..

If I do use it in the future (to make my work more efficient), I still
want to know how to do it..
 
M

Monique Y. Mudama

hhmm..

I want to learn to code in Java, not to use a program that will code
for me..

If I do use it in the future (to make my work more efficient), I
still want to know how to do it..

I think you're making the right decision. Eclipse can do a lot for
you, but it also takes a lot more work to set up than just firing up
an editor.

When you start working on projects with multiple packages, you may
find that Eclipse or a similar IDE is pretty nice. At some point you
will have enough classes and method names that you can't remember all
of your own code, and at that point auto complete is quite handy.

Anyway, Eclipse is a dog. I use it every day, but it is definitely a
slow memory hog.
 
S

Scott Ellsworth

Monique Y. Mudama said:
I think you're making the right decision. Eclipse can do a lot for
you, but it also takes a lot more work to set up than just firing up
an editor.

I disagree, actually. I find that those who use an IDE, like BlueJ,
tend to find packaging easier to get. If the IDE, like IDEA from
JetBrains, writes good accessors, and has good warnings and other
intentions, then they get a feel for decent code early.

Further, NetBeans, BlueJ, and IDEA are not that much more difficult than
a text editor, and they free you from having to understand classpath
issues until you need to.
When you start working on projects with multiple packages, you may
find that Eclipse or a similar IDE is pretty nice. At some point you
will have enough classes and method names that you can't remember all
of your own code, and at that point auto complete is quite handy.

I have been happier with people who learned those things early. YMMV,
of course, and it always helps to have a mentor around who can explain
what's what.
Anyway, Eclipse is a dog. I use it every day, but it is definitely a
slow memory hog.

I know what you mean about Eclipse. I am pretty happy with IDEA, while
BlueJ is meant for learning OO/Java.

Scott
 
X

x343181

i made a site to remember things and a complier help file is at the
beginning;

jonjon.0catch.com

hope it helps.
 
J

Jeffrey Schwab

John said:
You're going to be using both eventually -- so why not learn the right way?

If nothing else, I think the arguments over this topic have shown there
is no one right way.
Which is easier?

Entering your code, and pressing a button that says Compile/Run or dealing
with a million switches, paths, classpaths just to point things to where
you can make it compile?

That's an absurd over-simplification. I have used both IDEs and command
lines for years, and I vastly prefer the command-line.
Coast.

It's the only way...

Keep telling yourself that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top