LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Java Compiler in Ubuntu? (https://www.linuxquestions.org/questions/programming-9/java-compiler-in-ubuntu-686882/)

MexDeath 11-28-2008 10:38 AM

Java Compiler in Ubuntu?
 
Hi to all, I have a brief question:

When I type something that should be put in terminal, I use quotations, DO NOT use the quotations, I only use them to emphasise that what is inside the quotations should be typed as it is viewed by the reader, or to display the exact message that appears due to a command given.

How do I know if I have a Java Compiler in my Ubuntu Distribution?

For example, I know that most Linux (IFF not all) Distributions come with a C compiler (in my case, GCC). So, in order to check for a GCC compiler, all you do is go to (in Ubuntu 8.10) Applications>Acessories>Terminal, and type in:

"gcc" (Without quotations, of course)

If the GCC compiler is installed, you get a message that says:

"gcc: no input files" (Again, you wont see quotations)

Is there any similar way to do something like that for Java? If you need more information to answer my question, let me know, in detail, and I will provide it.

Rock on dudes and dudettes!

Peace,

MexDeath

nc3b 11-28-2008 10:46 AM

Following your method :D, in the terminal try

Code:

javac
PS, you might want to look at

Code:

dpkg -l
(since you are using ubuntu), or at least
Code:

which javac
Running a command just to see if it's there is not quite the best way to get info.

Cheers:)

jay73 11-28-2008 01:30 PM

java -version

MexDeath 11-28-2008 05:11 PM

Quote:

Originally Posted by jay73 (Post 3358080)
java -version

This is what I get...

Quote:

The program 'javac' can be found in the following packages:
* gcj-4.2
* jikes-sun
* jikes-sablevm
* kaffe
* jikes-kaffe
* java-gcj-compat-dev
* ecj
* gcj-4.3
* cacao-oj6-jdk
* openjdk-6-jdk
* jikes-classpath
* sun-java5-jdk
* sun-java6-jdk
Try: sudo apt-get install <selected package>

MexDeath 11-28-2008 05:13 PM

Quote:

Originally Posted by nc3b (Post 3357902)
Following your method :D, in the terminal try

Code:

javac

Well, I tried that, and this is what I get, and, I dont recognize any of those as Java Compilers, maybe you do?

Here is what I get:

Quote:

The program 'javac' can be found in the following packages:
* gcj-4.2
* jikes-sun
* jikes-sablevm
* kaffe
* jikes-kaffe
* java-gcj-compat-dev
* ecj
* gcj-4.3
* cacao-oj6-jdk
* openjdk-6-jdk
* jikes-classpath
* sun-java5-jdk
* sun-java6-jdk
Try: sudo apt-get install <selected package>

MexDeath 11-28-2008 05:16 PM

Quote:

Originally Posted by nc3b (Post 3357902)

PS, you might want to look at

Code:

dpkg -l
(since you are using ubuntu)

Well, I also tried that, and I saw a bit more than 1,000 lines of different programs and applications and other goodies. However, I saw nothing related to Java...
I wont quote 1k plus lines of terminal output on this thread :p

jay73 11-28-2008 05:31 PM

You want the sun-java6-jdk or the open source openjdk-6-jdk.

MexDeath 11-28-2008 08:49 PM

Choosing one.
 
Quote:

Originally Posted by jay73 (Post 3358241)
You want the sun-java6-jdk or the open source openjdk-6-jdk.

:Pengy:

Well, what is the difference, actually, which is more reliable?
Sun's or Open?
Also, like with OpenOffice, is this openjdk-6-jdk some sort of a project by Sun?
In either case, what do I do to use it? Do I have to instal it? Im relatively new to Linux (6 Months) and I have no clue as to what I should do after choosing any of them.


"Them" being (for anyone that wants to kick into this subject and help me out):
1. sun-java6-jdk
or
2. openjdk-6-jdk

Basically, my questions are:
1. What is the difference?
2. Does it matter?
3. How do I instal (If it isnt already)?
4. How do I make it work?

Thank you all!

:D

jay73 11-28-2008 10:59 PM

1. The Java language was invented and developed by Sun (yep, the guys who are also involved in Open Office). For many years, it was a proprietary language, which meant that it could not be freely distributed. This gave rise to open source alternatives that sought to reimplement the Java API. Most of these, however, were incomplete or lagged or had some other drawback so the Sun JDK remained the standard. Just last year, Sun changed their mind and released their JDK as open source. Now the problem is that some of the code in the Java API is owned by others and cannot be open sourced whether Sun want to or not. That is where the openjdk comes in: it seeks to rewrite those proprietary componenents in order to produce a jdk that is 100% as functional as the whole sun jdk without any proprietary element whatsoever.
2. For most purposes, no. The sun jdk does remain the reference implementation, though.
3. sudo aptitude install name_of_package (e.g. sudo aptitude install sun-java6-jdk).
4. nothing, on ubuntu, it should just work after doing 3 if you have not got any java package installed yet. If you have, then you need to switch the default (you can use galternatives to do so).

MexDeath 11-29-2008 04:59 PM

Thanks Jay, I'll see what happens...

Everybody put your helmets on!

MexDeath 11-30-2008 02:26 PM

About my Java Compiler.
 
Alright, so, as "Jay73" said, I ran the following command:
Code:

sudo apt-get install sun-java6-jdk
This isntalled my Java Compiler, I bet. Then, just to make sure, is this what I should be getting when I type:
Code:

javac
This is what I get:
Code:

mexdeath@mexdeath-desktop:~$ javac
Usage: javac <options> <source files>
where possible options include:
  -g                        Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}    Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                  Output messages about what the compiler is doing
  -deprecation              Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                Specify where to find user class files and annotation processors
  -sourcepath <path>        Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>      Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>            Specify where to place generated class files
  -s <directory>            Specify where to place generated source files
  -implicit:{none,class}    Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>      Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -version                  Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                        Print a synopsis of nonstandard options
  -J<flag>                  Pass <flag> directly to the runtime system

mexdeath@mexdeath-desktop:~$

Thank you.

MexDeath 11-30-2008 03:01 PM

Never Mind... that is it. I got it to work. Thank you all.


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