# Java



## Raistlfiren (Jul 14, 2004)

I just started messing with JAVA the other day and was wondering what this message was all about... I have got this same error message several times. I am using JCreator to compile and execute my JAVA programs. I could never figure out how out any of the other programs that I am supposedly supposed to be able to use... If anyone can tell me what Im doing wrong it would be a great help. 
Thanks,
Rat


----------



## Chicon (Jul 29, 2004)

Hi Raistlfiren,

Most of the classes used by Java are in the *rt.jar* library.
I don"t use JCreator but in your case, you should add the path of the library *rt.jar* to your *java.exe* command, for example :



> java.exe -classpath="YourPath/jre1.5.0_02/lib/rt.jar" PathOfYourApllication/YourApplicationClass


----------



## Raistlfiren (Jul 14, 2004)

Okay, I kind of lost you... Where do I put this at then? ::cough:: How do you access you java.exe cmd to? Sorry kind of lost...

By the way what programdo you use to program in JAVA?
Rat


----------



## Chicon (Jul 29, 2004)

Sincerely, I don't know JCreator. I am a JBuilder and Eclipse user.
To test your program, you can use Notepad and write a batch file (.BAT) on your Desktop with the following command for example :
*YourJavaPath/jre1.5.0_02/bin/java.exe -classpath="YourJavaPath/jre1.5.0_02/lib/rt.jar" PathOfYourApllication/YourApplicationClass*

And you launch your application double-clicking on the batch file icon.


----------



## Raistlfiren (Jul 14, 2004)

Oh Okay thanks... I tried out some other programs like NetBeans and the two you recommended; there is a lot to that you need to learn just about the program before you start! I tryed installing just the JDK developers platform onto my computer and using it, but I don't think it is working...

I set up the enviroment variable up, but when I go to compile it, it won't... Whenever I type in javac (file name).java into DOS prompt nothing is happening... I would think you would have to tell where the file is at. I was reading this tutorial : http://www.javacoffeebreak.com/tutorials/gettingstarted/part3.html. Oh well I believe I will be getting a book over the language before long. 
Thanks for your assistance,
Rat


----------



## dsovic (Aug 19, 2004)

Raistlfiren said:


> I set up the enviroment variable up, but when I go to compile it, it won't... Whenever I type in javac (file name).java into DOS prompt nothing is happening... I would think you would have to tell where the file is at.


Nothing is happening? You have either new line or message:
"'javac' is not recognized as an internal or external command, operable program or batch file."
If there is only new line, compiler succesfully comppiled Your code. Otherwise it returns error message(s)
JAVAC is in jdk/bin folder

I have just looked at You picture: beware because java is case-sensitive. Method "main" is not same as method "Main"; You can have them both in same code. Only method "Main" will execute automatically, method "main" should be called from within code.


----------



## Raistlfiren (Jul 14, 2004)

Hmmmm... So say my _javac_ file is in C:/Program Files/JAVA/.... and my program that is being compiled is in C:/(Username)/My Documents/Java Programs/... How would I do this in DOS prompt... Would it be the whole file address for both files to run the program in java?
Rat


----------



## gemjuggler (Jul 9, 2005)

At the DOS prompt, navigate to the directory where you have your .java file saved (ie the file you wish to compile)
For example, 

cd C:\(Username)\My Documents\Java Programs\...

(By the way, when using DOS to compile and run Java programs it helps if you avoid using space characters in file names - use JavaProg1.java not Java Prog 1.java)

Then type the following:

javac your_file_name_here.java

where your_file_name_here is obviously the name of your file 

Hope this is of some help. Also, when I began programming in Java I used a simple environment called RealJ at uni - is a small, (was free but think is now free to trial only but could be wrong) simple program. Wasn't fantastic but is straightforward for Java newcomers and I still use it to knock up small programs quickly.. try a google search for RealJ or FreeJava as it may now be known as!


----------



## Raistlfiren (Jul 14, 2004)

Hey,
I tryed looking for that program you told me about, but I can't find it anywheree. It is like the programmer of the app just left, because none of the downloads are working...

I was finally able to get my program compiled by doing

```
javac C:\Java\HelloWorld.java
```
. Though whenever I went to run the file by doing

```
java C:\Java\HelloWorld.java
```
 it gave me the following error :
_Registry key 'Software\Javasoft\Java Runtime Enviroment\Currentversion'
has valued '1.4', but '1.5' is required.
Error:could not find java.dll
Error:could not find Java 2 Runtime Enviroment._

To get the compiler working I had to update my enviromental variable\put it there... Could the program not be working because I have the wrong program installed? I installed this : jdk-1_5_0_04-nb-4_1-win, if this has any correlation to my problem... I also have in my C:\Program Files\Java folder is jdk1.5.0_04, jre1.5.0_02, and jre1.5.0_04.... Of course I directed my enviromental variable to C:\Program Files\Java\jdk1.5.0_04\bin.... 
Raistlin


----------



## dsovic (Aug 19, 2004)

You cannot execute .java file. Try java C:\Java\HelloWorld


----------



## Raistlfiren (Jul 14, 2004)

I am still gettting the same error message: 

Registry key 'Software\Javasoft\Java Runtime Enviroment\Currentversion'
has valued '1.4', but '1.5' is required.
Error:could not find java.dll
Error:could not find Java 2 Runtime Enviroment.
Rat


----------



## Chicon (Jul 29, 2004)

Raistlfiren said:


> ...Though whenever I went to run the file by doing
> 
> ```
> java C:\Java\HelloWorld.java
> ...


Your command is wrong : you should try java C:\Java\HelloWorld.*class*


----------



## Raistlfiren (Jul 14, 2004)

Okay thanks for your guys help! I got it all straightened out!
Rat


----------

