• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

How to compile hello world in eclipse?  RSS feed

 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Siegfried Heintze
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 19668
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!