Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-16-2004, 06:57 AM   #1
LQ Newbie
Registered: Sep 2004
Posts: 2

Rep: Reputation: 0
gcc/gcj and classpath on knoppix 3.6 (debian)

Hi, I'm trying to compile a simple helloworld on Knoppix 3.6. I get the following error when I run "gcc" or "gcc -x java"

Can't find default package 'java.lang' . Check the CLASSPATH environment variable and the access to the archives

Does anyone have any idea of what I should set the classpath to?
Old 09-16-2004, 08:01 AM   #2
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
gcc is the "c" compiler. It will compile only C code. g++ is the C++ compiler, which will compile only C++ code. That said, gcj is the one that can compile Java code.

You are trying to compile java code with the GNU C compiler. It won't work. Assuming that you have gcj installed, the syntax is exactly (or almost) as gcc to compile and link. E,g:

gcj -c -g -O
That will compile your code into a Hello.o (object file) but not link. To link it, use the command:
gcj --main=Hello -o Hello Hello.o
it's exactly like compiling a C program, with exception that you have to tell the compiler your main java class (in this case, Hello).
However, if you want to learn java, I'd recommend you getting into Sun's homepage and grab the Java SDK for Linux. There're binaries there for Linux, Windows and Solaris and they are equally easy to install.

Besides, gcj cannot yet compile graphical interfaces as Swing classes in Java. All the rest works fairly well though.

Good luck!
Old 09-16-2004, 02:38 PM   #3
LQ Newbie
Registered: Sep 2004
Posts: 2

Original Poster
Rep: Reputation: 0
thanks for your help, X, however I'm still getting the same error message

I will try sun's java sdk tomorrow


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upgrading gcc-3.4.3 from gcc-3.3.5 on Debian v3.1 MKSrivastava Debian 2 11-21-2005 11:09 PM
What's the difference between debian and other debian-based distro like knoppix? Akhran Debian 11 08-28-2005 07:07 PM
need help with gcj max_rsr Programming 1 05-24-2005 04:07 AM
installed gcc with java language enabled.. but no gcj ! qwijibow Linux - Software 3 10-15-2004 04:24 PM
gcc, gcj, and java problems weppnesp Linux - Software 0 06-15-2003 07:34 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration