aspose file tools*
The moose likes Linux / UNIX and the fly likes How to compile hello world in eclipse? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "How to compile hello world in eclipse?" Watch "How to compile hello world in eclipse?" New topic
Author

How to compile hello world in eclipse?

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
I notice my fedore core 4 has eclipse allready installed and compiled. I also notice that I have gcj installed instead of sun java.

When I tried to compile a trivial hello world java program, I get the a stack trace (see below). I noticed that JAVA_HOME was not defined so I did "export JAVA_HOME=/usr/bin" which is where it seemed to be.

However, I know java (gcj) is working correctly because the following works:

[siegfried@localhost hello_java]$ pwd
/home/siegfried/workspace/hello_java
[siegfried@localhost hello_java]$ javac hello/world/HelloWorld.java
[siegfried@localhost hello_java]$ java hello.world.HelloWorld
starting
all done

Unfortunately, defining JAVA_HOME did not help. Can someone tell me what is wrong?

Thanks,
Siegfried


Here is the stack trace from eclipse when I try to execute my simple java program:
Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: hello.world.HelloWorld
at java.lang.VMClassLoader.transformException(java.lang.Class, java.lang.Throwable) (/usr/lib64/libgcj.so.6.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class) (/usr/lib64/libgcj.so.6.0.0)
at java.lang.Class.initializeClass() (/usr/lib64/libgcj.so.6.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/libgcj.so.6.0.0)
at gnu.java.lang.MainThread.run() (/usr/lib64/libgcj.so.6.0.0)
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/siegfried/workspace/hello_java/,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib64/libgcj.so.6.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib64/libgcj.so.6.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib64/libgcj.so.6.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib64/libgcj.so.6.0.0)
...4 more
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

My $JAVA_HOME contains these:
, most of them being directories, including 'bin', which in turn includes java, javac and ...

Perhaps java is a symbolic link you may follow, to find the location where all that stuff is located.

If you like to use java-1.5 features, which is quiet common, you will have to get rid - at least disable - the blackdown-java-stuff, and get the sun-JDK.


http://home.arcor.de/hirnstrom/bewerbung
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
I was not aware that JAVA_HOME was like PATH in the sense it could contain multiple entries. Are these entries to be seperated by ":" like they are in PATH?

Thanks,
Siegfried
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16054
    
  21

JAVA_HOME points to the root directory of the JDK.

I personally find the "alternatives" system to be a royal pain when working with Java. But in any event, I don't think that the gcj system is complete enough to run Eclipse. I recomend downloading a Sun (or IBM) jdk, installing it, and pointing JAVA_HOME at the installed Java.


Customer surveys are for companies who didn't pay proper attention to begin with.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Sorry, Siegfried.
The JAVA_HOME variable points to the directory containing the listed files and directory.


might help getting rid of the default values.
Read the man-page for update-alternatives to get the details.
[ November 16, 2005: Message edited by: Stefan Wagner ]
 
wood burning stoves
 
subject: How to compile hello world in eclipse?