ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I'm am trying to learning java and I hava a few questions. First, I go to download the Java Developers Kit. Should I donwload the JRE or SDK ? Secondly how do i install something that is .bin. And lastly, my book is written for windows users. Can anyone give me what to do in linux for the following.
C:\>javac Example.java (for compiling)
C:\>java Example (for running)
You want the SDK (Software Development Kit). The JRE (Java Runtime Environment) is just for running java apps... not writing them.
to execute a .bin file the easiest way is to pass it to the shell...
sh j2sdk1.4.1_install.bin
and then finally the javac and java commands are the same on linux as on windows... just make sure that the jdk bin directory is in your path, that JAVA_HOME environment is setup and that your CLASSPATH is set up.
Originally posted by jpbarto just make sure that the jdk bin directory is in your path, that JAVA_HOME environment is setup and that your CLASSPATH is set up.
Lost you here.
Here is what I have
Code:
/*
This is a simple, simple app.
This is called First.java.
*/
class First {
public static void main(string args[]) {
}
}
I save this as First.java in my home directory. How should I comply it with the >javac commmand.
Thanks,
are you aware of the two common java environment variables?
JAVA_HOME
and
CLASSPATH?
JAVA_HOME points to the directory where java is installed.
for example my java compiler and sdk and everything is installed in /opt/j2sdk1.4.1
so at the command line I execute
export JAVA_HOME=/opt/j2sdk1.4.1
then the CLASSPATH contains a list of directories where Java can find its lib files (or your executable code)
so you'd want something like...
export CLASSPATH=$JAVA_HOME/lib:./
It doens't do anything, it just brings up another command prompt. Do I do >javac or just javac. And i always get a command not found with both. Do I have to have my code anyplace special like in /usr/java/j2sdk1.3.1_03/bin or can in just be in my home directory. Thanks for the help becaue I have no idea what I'm doing
After you write the java you can save it to anywhere.
issuing the command
javac First.java
will work if the javac executable (which resides in the bin directory of your java installation) is in your PATH environment variable.
after you execute
export PATH=$PATH:/usr/java/j2sdk1.4.1_03/bin
then execute
javac --help.
If javac prints out its usage then your command shell can find the javac compiler.
Thanks, it works. I tried to complie first but it would show a little ^ where I was missing something and I finally got it working.
Code:
/*
This is a simple, simple app.
This is called First.java.
*/
class First {
public static void main(String args[]) {
System.out.println("Whopeeee!!! I wrote JAVA");
}
}
Its primative and simple but I love it. Of course I might dig up this thread later if I get confused. Also, I found what I did wrong, I can only run javac from the /bin directory of my j2dk directory. Is there anyway around this?
Okey-dokey, it's good to keep a sense of humour about things. I'm the first to laugh at myself - which I need to do more often than not when there's a computer involved.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.