Results 1 to 4 of 4

Thread: problem compiling with JAVA

  1. #1

    Default problem compiling with JAVA

    hello, I am learning Java, on my first "Hello World" program, this is what I get

    alon@linux-6xrt:~/java> javac Ch2Sample1.java
    /usr/lib/gcc/i586-suse-linux/4.3/../../../crt1.o: In function `_start':
    /usr/src/packages/BUILD/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
    collect2: ld returned 1 exit status
    alon@linux-6xrt:~/java>


    I googled around but could not figure out. what is gcj?
    I am running openSUSE 11.1

    Thanks

  2. #2

    Default Re: problem compiling with JAVA

    Hello only-trouble,

    Quote Originally Posted by only-trouble
    hello, I am learning Java, on my first "Hello World" program, this is what I get
    Code:
                                                             alon@linux-6xrt:~/java> javac Ch2Sample1.java 
    /usr/lib/gcc/i586-suse-linux/4.3/../../../crt1.o: In function `_start':
    /usr/src/packages/BUILD/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115:  undefined reference to `main'
    collect2: ld returned 1 exit status
    alon@linux-6xrt:~/java>
    I googled around but could not figure out. what is gcj?
    I am running openSUSE 11.1

    Thanks
    Here's the homepage of gcj: GCJ: The GNU Compiler for Java - GNU Project - Free Software Foundation (FSF)

    It's a very strange error.
    I've never seen it before, maybe because I use an IDE.
    Do you have java-sun or openJDK?

    If you use java-sun what happens when you run this command:
    Code:
    /usr/lib/jvm/java-1.6.0-sun-1.6.0/bin/javac Ch2Sample1.java
    Just to make sure: I assume your file looks like this:
    Code:
    public class Ch2Sample1 {
    public static void main(String[] args) {
    System.out.println("Hello World!");
    }
    }
    If not could you post your source code.

    Best of luck!
    Where did I put my coffee cup?
    dir -R /home/* | grep "coffee cup"

  3. #3

    Default Re: problem compiling with JAVA

    Hello Edward,

    So I change the code to
    Code:
    public class hello2 {
    public static void main(String[] args) {
    System.out.println("Hello World!");
    }
    }
    and no change, still
    alon@linux-6xrt:~/java> javac hello2.java
    /usr/lib/gcc/i586-suse-linux/4.3/../../../crt1.o: In function `_start':
    /usr/src/packages/BUILD/glibc-2.9/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
    collect2: ld returned 1 exit status
    alon@linux-6xrt:~/java>
    I also discovered I dont have the directory
    /usr/lib/jvm/java-1.6.0-sun-1.6.0/bin
    this is the output of my directory

    alon@linux-6xrt:~/java> cd /usr/lib/jvm/
    alon@linux-6xrt:/usr/lib/jvm> ls
    java java-gcj jre-1.6.0-openjdk
    java-1.5.0 jre jre-gcj
    java-1.5.0-gcj jre-1.5.0 jre-openjdk
    java-1.5.0-gcj-4.3-1.5.0.0 jre-1.5.0-gcj
    java-1.6.0-openjdk-1.6.0 jre-1.6.0
    alon@linux-6xrt:/usr/lib/jvm>
    Where do I find my java compiler?
    I got the java compiler from the openSUSE repository.
    Where do I take it from here? Anysuggestions ? should I download the java compiler from the Sun website?
    Thanks

  4. #4

    Default Re: problem compiling with JAVA

    Hello only-trouble,

    Quote Originally Posted by only-trouble
    Where do I find my java compiler?
    I got the java compiler from the openSUSE repository.
    Where do I take it from here? Anysuggestions ? should I download the java compiler from the Sun website?
    Your java compiler isn't in the 'java-1.6.0-sun-1.6.0' directory because you most likely haven't got the java-sun version installed.
    By default the openJDK is installed.
    The only problem with it is that it some times doesn't work.

    So I recommend you install these packages:

    • java-1_6_0-sun
    • java-1_6_0-sun-devel
    • java-1_6_0-sun-plugin

    And remove all the java-1_6_0-openjdk packages.

    Then you've got the /usr/lib/jvm/java-1.6.0-sun-1.6.0/bin directory.
    But if you don't want to uninstall openJDK then the javac command is in:
    /usr/lib/jvm/java-1.6.0-openjdk-1.6.0/bin

    Good luck!
    Where did I put my coffee cup?
    dir -R /home/* | grep "coffee cup"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •