Archive: is JAVA installed?


is JAVA installed?
  Hi there,

does anybody know, how 2 check, if JAVA is installed and activated or not?
Some people deactivated JAVA or some Win98-users didn't install it at all.

Thanks for help
Tobias


I think you can check this in the registry...

but I don't know where to search

try to find the regkey of Java
(most simple way is imho to search for the installdir of it)

and then let your installer check for a value in this key...

should work

You may check if its activated somewhere in the regkey of the IE

but M$ unfortunatly encrypts its damn keys

just try it, should work as I said, maybe someone here knows where to search for it

hope this helps Dave


yeah, that's the only way... I thought of it, too.
Have to find my Win98se-CD and install it on my old machine.

I don't know, what key it is in Win98se :-)


don't know if it's similar on other systems, but on win2k there is a folder: "C:\WINNT\java\trustlib\com\ms\mtx"

there are a few .class files in it

if this folder depends on if java is installed or not you could check for some files?

just an idea...



[EDIT]
Found a better way:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Java VM

I think they ARE depending on an installed Java VM :D
[/EDIT]


ReadRegStr $JAVA_VER HKLM "SOFTWARE\JavaSoft\Java Runtime Environment"


or browse the archive, there are at least five answers and examples on doing this there. for example, here's one.


thanks


Hi I have a question regarding the above-mentioned link to the archives. I am a newbie to programming so I hope that these questions are not redundant.

From: Locate Java Runtime/JRE, ensure correct version, write CLASSPATH, PATH and JAVA_HOME to .bat file.

-----------------------------------------------------------
Section "JRE Locate and Set Path and Classpath Section"
JRECheckAndEnvSection
Call LocateJVM
StrCmp "" $JAVA_INSTALLATION_MSG Success OpenBrowserToGetJava

Success:
Call SetEnv
Goto Done

OpenBrowserToGetJava:
Exec '"explorer.exe" ${GET_JAVA_URL}'

Done:
SectionEnd
-----------------------------------------------------------
For the above code, is the JRECheckAndEnvSection a function?

and

-----------------------------------------------------------
Function SetEnv
Push $3
Push $4

FileOpen $4 "$INSTDIR\setEnv.cmd" w
StrCpy $3 "Set
CLASSPATH=$JAVA_HOME\jre\lib\rt.jar;$JAVA_HOME\lib\dt.jar;%CLASSPATH%"
FileWrite $4 "$3"
-----------------------------------------------------------
What is the purpose of the "w" on the line of:
FIleOpen $4 "$INSTDIR\setEnv.cmd" w

Thank you!



Section "JRE Locate and Set Path and Classpath Section" JRECheckAndEnvSection 

>
JRECheckAndEnvSection is the name to use for the section when enabling or disabling the section via the sections.nsh selectivity functions.


FIleOpen $4 "$INSTDIR\setEnv.cmd" w 

>
The w stands for opening the file in write mode. It could also be a for append, or r for read only.

Thanks zimsms. But when I compile the script using Make NSISW, it prompts me an error for JRECheckAndEnvSection. The error I get is Invalid Command

Do I have to declare JRECheckAndEnvSection or something? Thanks once again!!


Section "JRE Locate and Set Path and Classpath Section" JRECheckAndEnvSection


There's no new-line in there.

-Stu

Afrow UK, Thanks. I take it PHP uses wordwrap, and color where SOURCE uses neither?


Thanks! Really appreciate all your help.


Sorry...it's me again. I have to create an installer that will install and run Apache Tomcat server on the client's pc. I am just wondering if I am looking at the correct example from the archive. The example I am looking at is here


Sorry, I haven't done anything with NSIS and Apache. But this or this might help.


Thanks zimsms! Appreciate your help :)


Hi its me again. I have another question. I have to include in my installer a feature that will automatically update the class path and set the environment variables. I know that there are examples in the archive but I dont really understand them. I already have an example script that I think does this but I am not sure. I just want to know if I am on the right track. Here is the script. Thanks!


Hi I just wanted to know that if I had to place the script to check the java version together with my main script or place it in a new file or create a batch file for it. My script is attached below. Thanks!


Hi I have another question.

FileOpen $4 "$INSTDIR\setEnv.cmd" w
StrCpy $3 "Set CLASSPATH =
$JAVA_HOME\jre\lib\rt.jar;$JAVA_HOME\lib\dt.jar;%CLASSPATH%"
FileWrite $4 "$3"

What does the rt and the dt in StrCpy $3 "Set CLASSPATH =
$JAVA_HOME\jre\lib\rt.jar;$JAVA_HOME\lib\dt.jar;%CLASSPATH%" mean. And does this code automatically update the registry string when i run my installer. Thanks!

Hey...another question. My installer will have to automatically set the class path and the environment variables while it is extracting the files. The code that i refer to is this. Can someone please be kind enough to tell me if I am looking at the right script because my previous 3 questions have not been answered :cry:. But thats ok cause i managed to find out the answers to the previous 3 questions myself ;). And if I am not looking at the right script can someone pls inform me where i should be looking. This question has been really puzzling me. Thanks so much!

PS: As i mentioned in one of my earlier questions, I only have knowledge in Java and I am a student doing my attachment and have no knowledge on assembly language. So I apologise if this question seems redundant. Thanks again.


Use this.

To append to an existing variable you will first want to read in the current value, append the new value then push that onto the stack.


For Example, in this example we will append to the PATH variable.


Section "Append Env Var"
ReadEnvStr $0 "PATH"
Push "PATH"
Push "$0;c:\Example"
Call WriteEnvStr
SectionEnd


To create a new environment variable:


Section "Add Env Var"
Push "EXAMPLEVAR"
Push "MyExample"
Call WriteEnvStr
SectionEnd



Cheers!

P.S. Sorry for not replying to the others, I was on vacation.

Hey welcome back zimsms...hope you had a good vacation. Thanks for your help. I'll try it out and see if it works.


Hi...me again. I just want to know if I am on the right track. My installer will have to extract all the files that I am installing on its own. I am looking at the script example from this forum thread. Does this script do what I think it does i.e. extract the files while the software is being installed?

Thanks in advance!


No, it doesn't do what you think it does. What type of file do you need to extract (.zip, .rar. cab)? If your going to include a compressed file within your install your install will require more disk space (almost triple) in order to install. Why include a compressed file when the installer is going to compress it at compile time anyways.

However, if you want to proceed with installing a compressed file you will have to do the following. (In pseudocode)

; Reserve the file
Reservefile blah.cab
; in .oninit initialize the plugins folder
; in .oninit place the file into the plugins folder
setoutpath "$pluginsdir"
file /oname="$pluginsdir\blah.cab" "blah.cab"

; Then you would need to extract the cab file using the cab.dll plugin. (You can find this and examples on doing this easily by searching the forum. If your not using a cab file then do a search on zip or compression.

; continue with your install.


Thanks zimsms...I owe you big time for that tip you gave me about the installer compressing my files. I was not aware of that. I will use the default compression that the installer creates for me. Thank you once again for all your help. I really appreciate it!!


Hi. I have hit another brick wall.Here's my problem. Let's say if I were to install Java and the value of Java in the registry is lesser than the one that I am installing, my installer will have to update that value. It will also have to delete that value when I run the uninstaller. I am looking at one of the archive examples but am not sure if it is the right example and does what I need my installer to do. This is the script that I am looking at. I hope someone would be kind enough to tell me if I am on the right track.

Thanks in advance!


You can have more than one Java runtime or SDK installed at the same time. If you don't find the one you need in the registry, you should either, a) inform the user they need a specific version of the runtime and have them install it before proceeding, or b) install that specific requirement for them.

All that script does that you posted is append a specified string to the PATH environment variable. It's not really that useful in this situation unless you include the specific java runtime as part of your app and pre append the applications path to the PATH environment variable every time you start.

Anyways, I hope that helps.


Hi zimsms..i'm sorry but I did not really understand what your exlpanation in the second paragraph meant.For your understanding, i'll tell you what my installer already does.When the installer runs, it will extract the files and inform the user of the Java version they have in their system. If this version is lesser than j2sdk1.2, the installer will launch the j2sdk installation wizard. It should also update the registry once the installation i scomplete. I also have already placed the code that I took from the archive that I posted in my previous question. I have attached my script below for your reference. I just want to know if what you told me to include in my installer is already in my script and if they're not there, what i am missing. I'm sorry to keep bothering you but i'm really confused and I really appreciate all your help.

Thanks.


Quote:


Thanks zimsms! Your help is greately appreciated :D



I just want to know if what you told me to include in my installer is already in my script I looked at your script. Everything you said it was supposed to do is there, as well as, the portion I was talking about in the second paragraph.

I'm sorry to keep bothering you but i'm really confused and I really appreciate all your help.
Not a problem. That's why the forum exists. Besides, if I didn't have time to respond, I probably wouldn't! ;).