LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-30-2008, 03:01 AM   #1
mahi
LQ Newbie
 
Registered: Sep 2007
Location: mysore
Distribution: Debian
Posts: 16

Rep: Reputation: 0
how to compile java files in debian


hey people..
i'm trying to compile java files in debian using gcj but i'm gettin some error like..

/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../lib/crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status



my program is absolutely correct...
does anybody know wat the problem is and how to solve..
it would be a great help to know the solution so tat i can start
java programming in debian...
 
Old 10-30-2008, 03:43 AM   #2
maradnus
Member
 
Registered: Oct 2008
Location: Yellagiri Hills
Distribution: Fedora
Posts: 87

Rep: Reputation: 15
Lightbulb Simple problem

use

javac file.java
java file
 
Old 10-30-2008, 05:48 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
The problem is the java from 'gcj' and 'gij' , not working on
a lot of applications.

Debian Lenny :
My solution was to download all "sun" and dependencies from ubuntu :
Quote:
The target is : ubuntu package (intrepid) sun-java6-jdk_6-10-0ubuntu2_i386.deb :

sun-java6-jdk
http://packages.ubuntu.com/intrepid/...6-jdk/download
sun-java6-bin
http://packages.ubuntu.com/intrepid/...6-bin/download
odbcinst1debian1
http://packages.ubuntu.com/intrepid/...bian1/download
libltdl7
http://packages.ubuntu.com/intrepid/...ltdl7/download
unixodbc
http://packages.ubuntu.com/intrepid/...xodbc/download
sun-java6-jre
http://packages.ubuntu.com/intrepid/...6-jre/download
and then do
# dpkg -i sun-java6-bin_6-10-0ubuntu2_i386.deb sun-java6-jdk_6-10-0ubuntu2_i386.deb \
unixodbc_2.2.11-16build2_i386.deb sun-java6-jre_6-10-0ubuntu2_all.deb etc.
(or place all packages in a new directory and do # dpkg -i *)

Finally :
# update-alternatives --config java (please choose '..java-6-sun...')

Version test :
knudfl@debian:~$ java -version
java version "1.6.0_10"
knudfl@debian:~$ javac -version
javac 1.6.0_10
Regards

Last edited by knudfl; 10-30-2008 at 05:52 AM.
 
Old 10-30-2008, 06:22 AM   #4
craigevil
Senior Member
 
Registered: Apr 2005
Location: OZ
Distribution: Debian Sid/RPIOS
Posts: 4,884
Blog Entries: 28

Rep: Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533Reputation: 533
Do Not, I repeat Do NOT install ubuntu packages in a debian system.

If your using stable I would suggest using backports.

apt-get install sun-java6-jdk sun-java6-source sun-java6-bin sun-java6-plugin sun-java6-jre
should be more than enough to get you what you need,
 
Old 10-30-2008, 06:41 AM   #5
IsharaComix
Member
 
Registered: Sep 2008
Location: Raleigh
Distribution: Ubuntu 8.10
Posts: 88
Blog Entries: 1

Rep: Reputation: 15
If you're trying to compile Class files with gcj, use the gcj -C option. Works for me every single time.

~$gcj -C helloworld.java
~$java helloworld
 
Old 10-30-2008, 07:14 AM   #6
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
search on non-free repositories

Add this line to your /etc/apt/sources.list file:

deb ftp://ftp.debian.org/debian/ stable non-free

With this you will be able to install "non-free"(at least from the debian point of view) software, like sun's java. After doing this, you run synaptic, click "reload" and install the "sun-java5-jdk" package (or just run: sudo apt-get install sun-java5-jdk).
After this you will have javac and java and be able to compile/run your java programs.
 
Old 10-30-2008, 09:31 AM   #7
mahi
LQ Newbie
 
Registered: Sep 2007
Location: mysore
Distribution: Debian
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by IsharaComix View Post
If you're trying to compile Class files with gcj, use the gcj -C option. Works for me every single time.

~$gcj -C helloworld.java
~$java helloworld

Thanks... this worked... but is gcj as capable as javac???? i mean can i get all the utilities of javac or installing sun-java is better as suggested by other members.....???

Last edited by mahi; 10-30-2008 at 09:32 AM.
 
Old 10-30-2008, 10:08 AM   #8
IsharaComix
Member
 
Registered: Sep 2008
Location: Raleigh
Distribution: Ubuntu 8.10
Posts: 88
Blog Entries: 1

Rep: Reputation: 15
Java bytecode is Java bytecode. What gcj does by default is try to make your .java files into architecture-dependant binaries. You need to tell it not to do that and instead make files that are read by whatever JRE you are using.

If you want to make GUI applications, you can install the OpenJDK Java Runtime Environment, and still compile stuff with the gcj. That's what I do. The gij doesn't read swing very well.

Note: when it comes to linking, I'm no expert. But for the most part, the biggest thing about making Java classes is the fact that they are able to be ported to other operating systems without modification. That's what the gcj -C invocation is so useful.

What you do is your business. I'm not going to say what I do is better than what anybody else does.

Happy hacking.
 
  


Reply

Tags
debian



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
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
cant compile java files in fedora 8.. java/ maranganesan Linux - Software 4 12-31-2007 12:21 PM
Firefox refuses to load Java jnlp files - plugin and java ok Melsync Linux - Software 1 06-25-2006 04:09 PM
Compile Java - .class, .java, .jar ? woranl Programming 2 11-09-2004 10:12 PM
Java: Compile Large number of source files ? mikeshn Programming 7 10-07-2003 11:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:57 PM.

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