Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Compiling Java in a terminal

  1. #1

    Compiling Java in a terminal

    Hi,

    I am using Fedora core 5 32+ bit as my os on the pc. I want to learn Java a bit on my own. Can I compile Java code from the terminal itself? I am not used to any particular IDE at the moment so terminal seems to be the best way forward as I have been doing this with my sample C++ codes as well. I would appreciate any further guidance in terms of what is the best way to start programming in Java on Fedora platform. Thanks a lot gentlemen.

  2. #2
    hello,
    yes - fedora uses javac for the compiler - that comes with eclipse
    telnet mtrek.game-host.org 1701

  3. #3
    Member omidkamangar's Avatar
    Join Date
    Mar 2006
    Location
    Kurdistan
    Posts
    239
    Quote Originally Posted by pbharris View Post
    hello,
    yes - fedora uses javac for the compiler - that comes with eclipse
    I think this is not the Java from Sun. It is an extension of gcc or something like that (not sure). I use Sun Java myself. All you need is to download and isntall the JDK. You can find it on the Sun.com.
    And some good books which I recommend:
    The Java tutorial from Sun microsystems.
    Core Java Vol I,II. again from Sun microsystems.

    The first one is free to download from Sun.com, but the other ones are not free.
    Good luck with Java.
    This will be over soon, and then I can ...

  4. #4
    Quote Originally Posted by omidkamangar View Post
    I think this is not the Java from Sun. It is an extension of gcc or something like that (not sure). I use Sun Java myself. All you need is to download and isntall the JDK. You can find it on the Sun.com.
    And some good books which I recommend:
    Thanks a lot first of all. I fully agree with you in the sense that I need to install JDK in order to make the best of my Fedora installation's in built Java specific capabilites. I have got a few questions though which need further clarification.

    1. I agree that I need to go for JDK, but if I try the following in a terminal this is what I get as a result of running the command:

    [root@localhost ~]# yum install java
    Loading "installonlyn" plugin
    Setting up Install Process
    Setting up repositories
    dries [1/6]
    dries 100% |=========================| 951 B 00:00
    core [2/6]
    core 100% |=========================| 1.1 kB 00:00
    updates [3/6]
    updates 100% |=========================| 1.2 kB 00:00
    freshrpms [4/6]
    freshrpms 100% |=========================| 951 B 00:00
    macromedia [5/6]
    macromedia 100% |=========================| 951 B 00:00
    extras [6/6]
    extras 100% |=========================| 1.1 kB 00:00
    Reading repository metadata in from local files
    Parsing package install arguments
    Nothing to do


    As it says 'nothing to do', should I automatically assume that the native support for Java for my Fedora core 5 os is now enabled? Is this action (running the command yum install java) going to affect the successful running of Java on my pc after I install the necessary stuff from Sun website?

    2. Now I have already run the command 'yum install java', so I tried to see if it was installed by typing this command which I am quite unsure of.

    [root@localhost ~]# rpm -qi java
    package java is not installed


    Here it says 'package java is not installed'. What does this suppose to mean?

    3. I have been looking around the net on various Linux forums and people have been telling me different things when I ask a simple question like what actually I need to download from Sun's site to run Java perfectly. Some are saying that I need only one thing and that is JRE, not JDK.

    So I searched on the net and came across this page for Linux download for Java. It does not say whether it is JRE or JDK.

    http://www.java.com/en/download/linux_manual.jsp

    I just downloaded the file Linux RPM (self-extracting file) filesize: 17.67 MB and followed this page for the installation of it.

    http://www.java.com/en/download/help/5000010500.xml#rpm

    Now when I type this command in a shell this is what I get:

    [root@localhost ~]# rpm -qi jre
    Name : jre Relocations: /usr/java
    Version : 1.6.0_01 Vendor: Sun Microsystems, Inc.
    Release : fcs Build Date: Wed 14 Mar 2007 10:56:32 AM GMT
    Install Date: Sun 27 May 2007 01:50:40 PM BST Build Host: jdk-lin-1586
    Group : Development/Tools Source RPM: jre-1.6.0_01-fcs.src.rpm
    Size : 45843609 License: Sun Microsystems Binary Code License (BCL)
    Signature : (none)
    Packager : Java Software <jre-comments@java.sun.com>
    URL : http://java.sun.com/
    Summary : Java(TM) Platform Standard Edition Runtime Environment
    Description :
    The Java Platform Standard Edition Runtime Environment (JRE) contains
    everything necessary to run applets and applications designed for the
    Java platform. This includes the Java virtual machine, plus the Java
    platform classes and supporting files.

    The JRE is freely redistributable, per the terms of the included license.


    So this means that JRE is installed properly on the system then? Or does it mean that I no longer need JDK?

    I am sorry for the length of the post, but I hope that someone like you can clarifiy the doubts and confusions that are bothering me at the moment. Thanks....

  5. #5
    Member omidkamangar's Avatar
    Join Date
    Mar 2006
    Location
    Kurdistan
    Posts
    239
    First of all when you include commands in your posts use code tag.

    Quote Originally Posted by tech291083 View Post
    As it says 'nothing to do', should I automatically assume that the native support for Java for my Fedora core 5 os is now enabled?
    I think (not sure) this command is going to install gcc version of Java.
    Quote Originally Posted by tech291083 View Post
    I just downloaded the file Linux RPM (self-extracting file) filesize: 17.67 MB and followed this page for the installation of it.

    http://www.java.com/en/download/help/5000010500.xml#rpm

    Now when I type this command in a shell this is what I get:

    [root@localhost ~]# rpm -qi jre
    Name : jre Relocations: /usr/java
    Version : 1.6.0_01 Vendor: Sun Microsystems, Inc.
    Release : fcs Build Date: Wed 14 Mar 2007 10:56:32 AM GMT
    Install Date: Sun 27 May 2007 01:50:40 PM BST Build Host: jdk-lin-1586
    Group : Development/Tools Source RPM: jre-1.6.0_01-fcs.src.rpm
    Size : 45843609 License: Sun Microsystems Binary Code License (BCL)
    Signature : (none)
    Packager : Java Software <jre-comments@java.sun.com>
    URL : http://java.sun.com/
    Summary : Java(TM) Platform Standard Edition Runtime Environment
    Description :
    The Java Platform Standard Edition Runtime Environment (JRE) contains
    everything necessary to run applets and applications designed for the
    Java platform. This includes the Java virtual machine, plus the Java
    platform classes and supporting files.

    The JRE is freely redistributable, per the terms of the included license.


    So this means that JRE is installed properly on the system then? Or does it mean that I no longer need JDK?
    As it says it is JRE not JDK. To install compiler and other tools you need to download JDK.
    You can download JDK from here.
    http://java.sun.com/javase/downloads/index.jsp
    You can also download NetBeans from that link. It is a very powerfull IDE for Java.
    Aftre you downloaded the file install it, and add the java's compiler path to the PATH environment variable too. If you encountered any problems post them here (remember the code tag ).
    This will be over soon, and then I can ...

  6. #6
    Quote Originally Posted by omidkamangar View Post
    First of all when you include commands in your posts use code tag.

    You can also download NetBeans from that link. It is a very powerfull IDE for Java.
    Aftre you downloaded the file install it, and add the java's compiler path to the PATH environment variable too. If you encountered any problems post them here (remember the code tag ).
    Thanks a lot and sorry for the commands not being tagged as code. I am a lazy man. Right so as far as I understand from the link to the page that you have given me is I can go for any of these

    JDK 6u1
    JDK 6u1 with Java EE
    JDK 6u1 with NetBeans 5.5.1

    and the one that you have mentioned as NetBeans is the third on the page ie
    JDK 6u1 with NetBeans 5.5.1

    From the page :

    http://java.sun.com/javase/downloads/index.jsp

    Right?

    Thanks for the help I just needed some proper guidance then I will be alright.

  7. #7
    I think this is the one with NetBeans then:


    Java SE Development Kit and NetBeans IDE Cobundle (JDK 6u1 / NB 5.5.1)
    and here is the page:

    https://sdlc6c.sun.com/ECom/EComActi...8C1DE79EB8FB8B


    Linux Platform - Java SE Development Kit and NetBeans IDE Cobundle (JDK 6u1 / NB 5.5.1)

    Java SE Development Kit and NetBeans IDE Cobundle (JDK 6u1 / NB 5.5.1), Multi-language jdk-6u1-nb-5_5_1-linux-ml.bin 140.61 MB

  8. #8
    Just installed it ie JDK 6u1 with NetBeans 5.5.1

    but when I try to compile a small file called james.java saved in a folder called PracJava on desktop, from the terminal with the following commands it for some reason gives the following error:
    Code:
    [root@localhost ~]# cd Desktop/PracJava
    [root@localhost PracJava]# javac james.java
    /usr/bin/javac: line 3: java: command not found
    [root@localhost PracJava]#
    Here is the cod of the file named james.java
    Code:
    public class google
     {
          public static void main(String args[]) {
             System.out.println("Hello Mr. Bond, nice to see you!");
          }
       }
    Can some one suggest me something?

    Thanks

  9. #9
    i just did the following
    Code:
    [root@localhost ~]# su
    [root@localhost ~]# whereis netbeans
    netbeans: /opt/netbeans-5.5.1/bin/netbeans
    [root@localhost ~]# cd /opt
    [root@localhost opt]# ls
    jdk1.6.0_01             jre-6u1-linux-i586-rpm.bin  netbeans-5.5.1
    jre-6u1-linux-i586.rpm  libjavaplugin_oji.so
    [root@localhost opt]#
    One thing here is strange, libjavaplugin_oji.so is flashing in a red background. Is it some kind of error that needs to be corrected?

    Thanks...

  10. #10
    Member omidkamangar's Avatar
    Join Date
    Mar 2006
    Location
    Kurdistan
    Posts
    239
    Sorry for being late, I couldn't access internet in the last 24 hours
    Quote Originally Posted by tech291083 View Post
    Just installed it ie JDK 6u1 with NetBeans 5.5.1

    but when I try to compile a small file called james.java saved in a folder called PracJava on desktop, from the terminal with the following commands it for some reason gives the following error:
    Code:
    [root@localhost ~]# cd Desktop/PracJava
    [root@localhost PracJava]# javac james.java
    /usr/bin/javac: line 3: java: command not found
    [root@localhost PracJava]#
    Here is the cod of the file named james.java
    Code:
    public class google
     {
          public static void main(String args[]) {
             System.out.println("Hello Mr. Bond, nice to see you!");
          }
       }
    Can some one suggest me something?

    Thanks
    You have chosen the right one.
    In Java programs the name of the file containing the main function must be the same as the class containing the main function. In this case it must be google.java not james.java.
    And have you added the path containing the java program to the PATH environment variable?
    This will be over soon, and then I can ...

Similar Threads

  1. Replies: 5
    Last Post: 04-30-2007, 08:43 PM
  2. terminal help
    By nader43 in forum Linux - General Topics
    Replies: 1
    Last Post: 02-10-2007, 07:21 AM
  3. java and opera... always says invalid java directory
    By sujoki in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 08-26-2003, 03:54 PM
  4. terminal & hd
    By BurntAsh in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 01-08-2003, 10:37 PM
  5. Java & Mozilla (formerly Java and Netscape)
    By papanohair in forum Linux - General Topics
    Replies: 2
    Last Post: 01-07-2002, 08:21 PM

Bookmarks

Posting Permissions

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