aspose file tools*
The moose likes Beginning Java and the fly likes Problem with basic HelloWorld app - wrong version? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem with basic HelloWorld app - wrong version?" Watch "Problem with basic HelloWorld app - wrong version?" New topic
Author

Problem with basic HelloWorld app - wrong version?

Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
My son is trying to teach himself Java and was in the process of going thru the tutorials on the oracle website. We had installed JDK version 1.6.0_26 and he was able to successfully get it to work. As he was going thru the tutorials, it stated that the tutorials were designed to work best with JDK 7, and he should update his java, so he did.

After installing the new version, he now gets this message when trying to run the java command:

Registry key 'Software\JavaSoft\Java Runtime Environment\CurrentVersion'
has value '1.7', but '1.6' is required.
Error: could not find java.dll
Error: could not find Java SE Runtime Environment.

We went thru and uninstalled all versions of Java, and then reinstalled version 7. He still gets the same message. We uninstalled again, and reinstalled JDK 6 - no problems. Should we just stick with JDK 6, or is there a way to fix this. I've checked the registry, and it only lists version 1.7
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10384
    
    8

Welcome to the Ranch.

How did you uninstall? Did you just delete the folder?

Purely from the learning perspective, it should not matter if its 6 or 7. Only thing you need to remember is that you won't be able to use the features which were added in 7. But from a beginner's perspective, it won't make any difference.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Walter Gabrielsen Iii
Ranch Hand

Joined: Apr 09, 2011
Posts: 158
Okay, there are two parts to Java. The Runtime version (RE) for running Java, and the separate Java Software Development Kit (sdk). It could be possible that you have version 7 of the SDK but version 6 of the RE.

When you install the Java 7 SDK, there should be an option to install both the SDK and the RE. Could this have somehow been deselected during your installation?

It is also possible that your computer is pointing to the wrong Java directory. This can happen if you previously set your computer's class path, the environment variables pointing towards the directory that Java's SDK tools are in, to an earlier version of Java's development kit.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Just to add on, has he tried executing the command from the JRE installation directory? It will work for sure if its executed from the JDK's bin directory since there won't be any version and path conflicts.


SCJP, SCWCD.
|Asking Good Questions|
Prince Sewani
Ranch Hand

Joined: Nov 24, 2010
Posts: 32
Well,I'd like to mention the following things :

1. It could be an installation problem - only the case when you uninstall and reinstall (improperly).

2. Version Conflicts occur when you update Java using the the 'Java Update Available' Icon in windows of 'update manager' in linux and the PATH variable
refers still to the older version.

3. The CLASSPATH variable(if set) shall always contain a '.' after a semicolon after what so ever it has been defined to point at.

Regards
Prince


Regards
Prince
---------------------------------------------------------
SCJP 6 , still a life long learner
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Thanks for all the feedback everyone.

We have uninstalled and reinstalled a couple times using the add/remove tool in the control panel. It does ask during the installation to install the RE and it is version 7. I have automatic updates turned off.

Here are how we set the PATH variables:
Under user variables: C:\Program Files\Java\jdk1.7.0\bin (it is named JAVA_HOME)

under system: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Windows Live\Shared;C:\Program Files\Java\jdk1.7.0\bin\;

We have not changed anything to the CLASSPATH - we didn't read anywhere on the oracle site about changing it, or what it does. When I checked it, it does have jre6 - here it is:

.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip

Do I need to change that to jre7? Why do I still have a jre6 folder inside the java folder after downloading 7?

Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Oh, I should add to say that the javac command works with 7 - it's only the java command that we are having problems with.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38896
    
  23
That error is typical of what you get when you compile with a Java7 javac tool and try to run it with a Java6 or older java tool.

The classpath appears to have been set when you installed quicktime. Unless you have uninstalled quicktime, leave it unchanged. Quicktime will need the QT link and it has added the bit you want, viz ".", where you want it, at the beginning.
There are likely to be java tools inside the Windows® folders in your PATH. Take out the reference to jdk1.7.0 from the end of your PATH and replace it at the beginning. Obviously your computer is going through the PATH and finding a Java6/1.6 "java.exe" program in one of those Windows® folders before getting to the jdk1.7 folder.
Putting the jdk1.7 path at the start of the PATH will mean your most up-to-date version of java.exe will be found first. Once the computer has found one version of "java.exe", it will stop looking.
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Amit Ghorpade wrote:Just to add on, has he tried executing the command from the JRE installation directory? It will work for sure if its executed from the JDK's bin directory since there won't be any version and path conflicts.


Ok, the java command works when it is executed from the jre7 directory. Does that mean he should save all his apps into this folder instead?


Campbell Ritchie wrote:Putting the jdk1.7 path at the start of the PATH will mean your most up-to-date version of java.exe will be found first. Once the computer has found one version of "java.exe", it will stop looking.


Did this, but we still get the error when running Java from the java directory.

Thanks again for all the help - we will keep trying.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38896
    
  23
Suzanne Mir wrote: . . . Ok, the java command works when it is executed from the jre7 directory. Does that mean he should save all his apps into this folder instead?
No. Create your own directory. "mkdir java" or similar. Now you can gain access to that directory with "cd java".
Suzanne Mir wrote: . . .
Campbell Ritchie wrote:Putting the jdk1.7 path at the start of the PATH . . .


Did this, but we still get the error when running Java from the java directory.

Thanks again for all the help - we will keep trying.
Did you open a new command line? The change is not applied until you open an new command window.
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Campbell Ritchie wrote:

Did you open a new command line? The change is not applied until you open an new command window.


Yes, and restarted the computer with fingers crossed. He's been able to get some more practice in thru the jre dir, so it's moving along now. It's just frustrating that I can't figure out what the problem is.

One thing I remembered - we installed windows 7 a few months back, and it created a folder of our old system with all the programs and files - we had java installed on the old system. Would that be creating a problem? Although I don't see how.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38896
    
  23
Did you install Java on the new OS? If you are using Java7, probably yes, since Java7 has only been available for about two weeks.
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Yes, we installed Java 7 on the new OS - that's when all the problems started. When we had java 6, there were no problems.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38896
    
  23
Can you uninstall Java7 and do a system restore to before you installed it?
sasanka mandavilli
Greenhorn

Joined: Aug 14, 2011
Posts: 1
go to
C:\Program Files\Java\jdk1.7.0\bin
and click java.exe file
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Campbell Ritchie wrote:Can you uninstall Java7 and do a system restore to before you installed it?


I tried that - went to the point before I uninstalled 6 - tested 6 and everything worked. I uninstalled 6, and then installed 7. Same problem.


sasanka mandavilli wrote:go to
C:\Program Files\Java\jdk1.7.0\bin
and click java.exe file


I did this - a cmd window briefly appears, then closes. I still get the registry key error.


On a side note - I really appreciate everyone offering so much help. I posted this on a couple other forums and only got one reply.
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

I would stick with Java 1.6 then.
Java 1.7 isn't different from an absolute beginner point of view.
I really envy your effort.


Please correct my English.
Prince Sewani
Ranch Hand

Joined: Nov 24, 2010
Posts: 32
Well, I think I'm able to figure it out nearly..

Suzanne Mir wrote:
Campbell Ritchie wrote:

Did you open a new command line? The change is not applied until you open an new command window.


Yes, and restarted the computer with fingers crossed. He's been able to get some more practice in thru the jre dir, so it's moving along now. It's just frustrating that I can't figure out what the problem is.

One thing I remembered - we installed windows 7 a few months back, and it created a folder of our old system with all the programs and files - we had java installed on the old system. Would that be creating a problem? Although I don't see how.


No that ain't a problem at all, your problem is here :

Suzanne Mir wrote:
under system: C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Windows Live\Shared;C:\Program Files\Java\jdk1.7.0\bin\;


What I presume from reading all your comments and observing it is :
You upgraded to java 7 using some auto upgrade be it from the "Java Update Available Icon" or some other setup from Oracle's website.

What you gotto do is :

1. Uninstall all Java versions what so ever you have installed on your pc,be it jre/jdk/patch.
2. Check registry entry if it's still showing a sign of 1.7(I'm not sure but it will show perhaps)
3. Remove the reference to Java 7 from system variable "PATH" and all the user variables that you set for Java(Any version,anything)
4. Restart and install Java 7
5. In User Variables section just create these two variables :
a) name :JAVA_HOME
value : C:\Program Files\Java\jdk1.7.0 or whatsoever is the jdk install directory home variable shall only point to the jdk install directory and not to its bin.

b) name : PATH
value : .;%JAVA_HOME%\bin

After this it shall work fine, and you shall be able to create any java program anywhere(in any folder,any location)
and do javac and java any number of times.

Hope it helps.

Regards
Prince
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38896
    
  23
Prince Sewani wrote: . . .
b) name : PATH
value : .;%JAVA_HOME%\bin . . .
That PATH is incorrect; you should not usually include . in the PATH. Make sure to put the Java™ part of the PATH first.
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
Campbell Ritchie wrote:
Prince Sewani wrote: . . .
b) name : PATH
value : .;%JAVA_HOME%\bin . . .
That PATH is incorrect; you should not usually include . in the PATH. Make sure to put the Java™ part of the PATH first.


so should it just look like this: %JAVA_HOME%\bin ?

Either way, it still isn't working after I follow the steps from Prince. I still get the same error saying that 1.6 is required instead of 1.7 The javac command works, but not java.
Prince Sewani
Ranch Hand

Joined: Nov 24, 2010
Posts: 32
@Campbell,

Sir,

For me the Path variable works fine ever since I've been using windows.

@Suzanne

Did you delete the directories after you uninstalled all the versions?
At times for softwares/utilities part of files still remain in the install directory, make sure you do a complete cleanup.

The second question is after you uninstalled are there any references to java in the registry?


Suzanne Mir wrote:
Campbell Ritchie wrote:
Prince Sewani wrote: . . .
b) name : PATH
value : .;%JAVA_HOME%\bin . . .
That PATH is incorrect; you should not usually include . in the PATH. Make sure to put the Java™ part of the PATH first.


so should it just look like this: %JAVA_HOME%\bin ?

Either way, it still isn't working after I follow the steps from Prince. I still get the same error saying that 1.6 is required instead of 1.7 The javac command works, but not java.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38896
    
  23
. . . but Suzanne Mir's path isn't. It is as a general rule a bad idea to delete folders unless you created them yourself.
Prince Sewani
Ranch Hand

Joined: Nov 24, 2010
Posts: 32
But then,when we installed it got created,so, when we un-install it should be removed as well isn't it?

Campbell Ritchie wrote: . . . but Suzanne Mir's path isn't. It is as a general rule a bad idea to delete folders unless you created them yourself.
Suzanne Mir
Greenhorn

Joined: Aug 12, 2011
Posts: 9
There is still a java folder in the registry after I uninstall Java. When all this started, I was following someone else's directions and deleted the java folder from the registry after the uninstall. It didn't seem to make a difference.
Prince Sewani
Ranch Hand

Joined: Nov 24, 2010
Posts: 32
Well that's it, that's the root cause to your problem..even after you uninstall Java 6 is being referred from the system..
and when you install Java 7 and configure path for it.. at runtime the JRE versions raise a conflict..you need to figure out how to solve that..

If you get it resolved..you're done..else you just have one option to make everything go fine as it should be hope you know what it is..because that's the last and master choice everyone picks for windows..

Suzanne Mir wrote:There is still a java folder in the registry after I uninstall Java. When all this started, I was following someone else's directions and deleted the java folder from the registry after the uninstall. It didn't seem to make a difference.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with basic HelloWorld app - wrong version?