This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 139031

Summary: WTK2.5.2 emulator doesn't start if java binary is not in PATH
Product: javame Reporter: Andrei Chistiakov <ca-nb>
Component: Build SystemAssignee: Petr Suchomel <psuchomel>
Status: RESOLVED WONTFIX    
Severity: blocker CC: dlipin
Priority: P2 Keywords: RELNOTE
Version: 6.x   
Hardware: All   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:
Attachments: output
output in verbose mode

Description Andrei Chistiakov 2008-07-04 12:32:18 UTC
Reproduced with NetBeans IDE Dev (Build 200807020103).

If PATH environment variable doesn't contain substring like "C:\Program Files\Java\jdk1.6.0_04\bin" pointing at java
executable, emulator doesn't start when I try to run CLDC/MIDP application.
Comment 1 Petr Suchomel 2008-07-04 14:51:58 UTC
This is as designed. It allows user to run any WTK and all related tools by providing JAVA on PATH variable. Hard coding
Java PATH had a significant side effect when upgrading JAVA, using different version etc. I understand, this can have
sometimes impact, but we are not able to provide better solution.
Comment 2 Ivan Sidorkin 2008-07-04 18:26:28 UTC
this issue should be solved somehow
we ship WTK with NetBeans, so it should work
if you can't pass java path to emulator you should show user some error message, because now it almost impossible to
understand root problem when emulator not started
Comment 3 dlipin 2008-07-06 09:48:08 UTC
If emulator is started as the separate process from the IDE, then, I guess, the new process environment can be 
customized so that java executable would be in path, i.e. PATH environment variable can be prepended by the "$JAVA_HOME/
bin:" ("JAVA_HOME\bin;" on Windows) where $JAVA_HOME is path of JDK that NetBeans run on. 
This can be done using ProcessBuilder instead of Runtime.getRuntime().exec() that is used now, at least, for Nokia and 
Sun emulators, I cannot say anything about microemu/mpowerplayer.
Does it make sense?
Comment 4 dlipin 2008-07-10 08:17:01 UTC
another option is to use Runtime.getRuntime().exec(String []commands, String [] envp).
Comment 5 Petr Suchomel 2008-07-11 12:20:45 UTC
Sorry my first evaluation was wrong, I overlooked some key details. Fix your Java installation first, the problem is not
in missing Java on PATH but in broken registry. On Windows, WTK searches for registry to find JDK to run on, so no need
PATH variable set.
Generally, Java is set up by inheritance from Ant, so for example on Linux, even when you do not have Java on PATH, this
variable is propagated to emulator environment through Ant environment.
Comment 6 Andrei Chistiakov 2008-07-11 12:31:19 UTC
Could you please provide the exact registry key that should exist on Windows and allows the emulator to find java?
Comment 7 Ivan Sidorkin 2008-07-11 12:32:43 UTC
even the problem is in Java installation you should provide user some info that emulator cannot start for some reason
Comment 8 Petr Suchomel 2008-07-11 12:44:12 UTC
I think it says it can not find. Actually all these are 3rd party binaries and for us it is just failing process. If
process gives any info, it is displayed in the output tab, but we can not influence this in any way.
Comment 9 Petr Suchomel 2008-07-11 12:45:36 UTC
I can try to find the key, but it'll take me a several days at least, I do not have access to sources (we do bundle
binary package). I have to find someone who can provide me with such information.
Comment 10 Andrei Chistiakov 2008-07-11 12:59:44 UTC
NetBeans IDE Dev (Build 200807100006).

The exact output is as follows:

pre-init:
pre-load-properties:
exists.config.active:
exists.netbeans.user:
exists.user.properties.file:
load-properties:
exists.platform.active:
exists.platform.configuration:
exists.platform.profile:
basic-init:
cldc-pre-init:
cldc-init:
cdc-init:
ricoh-pre-init:
ricoh-init:
semc-pre-init:
semc-init:
savaje-pre-init:
savaje-init:
nokiaS80-pre-init:
nokiaS80-init:
nsicom-pre-init:
nsicom-init:
post-init:
init:
conditional-clean-init:
conditional-clean:
pre-clean:
clean-timestamp:
clean-preprocessed:
clean-classes:
clean-obfuscated:
clean-preverified:
clean-manifest:
clean-jar:
clean-jad:
clean-javadoc:
clean-j9:
clean-ricoh:
clean-semc:
clean-savaje:
Deleting: C:\MyProjects\SunSamples-Demos1\convert1771768208
post-clean:
do-clean:
deps-jar:
pre-preprocess:
do-preprocess:
Created dir: C:\MyProjects\SunSamples-Demos1\build\preprocessed
Pre-processing 23 file(s) into C:\MyProjects\SunSamples-Demos1\build\preprocessed directory.
Copying 7 files to C:\MyProjects\SunSamples-Demos1\build\preprocessed
post-preprocess:
preprocess:
pre-compile:
extract-libs:
Created dir: C:\MyProjects\SunSamples-Demos1\build\compiled
do-compile:
Compiling 23 source files to C:\MyProjects\SunSamples-Demos1\build\compiled
Copying 7 files to C:\MyProjects\SunSamples-Demos1\build\compiled
post-compile:
compile:
pre-obfuscate:
proguard-init:
skip-obfuscation:
proguard:
post-obfuscate:
obfuscate:
pre-preverify:
do-preverify:
Created dir: C:\MyProjects\SunSamples-Demos1\build\preverifysrc
Copying 44 files to C:\MyProjects\SunSamples-Demos1\build\preverifysrc
Created dir: C:\MyProjects\SunSamples-Demos1\build\preverified
Preverifying 44 file(s) into C:\MyProjects\SunSamples-Demos1\build\preverified directory.
Copying 7 files to C:\MyProjects\SunSamples-Demos1\build\preverified
post-preverify:
preverify:
pre-jar:
set-password-init:
set-keystore-password:
set-alias-password:
set-password:
create-jad:
Created dir: C:\MyProjects\SunSamples-Demos1\dist
add-configuration:
add-profile:
do-extra-libs:
Created dir: C:\MyProjects\SunSamples-Demos1\dist\lib
nokiaS80-prepare-j9:
nokiaS80-prepare-manifest:
nokiaS80-prepare-manifest-no-icon:
nokiaS80-create-manifest:
semc-build-j9:
do-jar:
Building jar: C:\MyProjects\SunSamples-Demos1\dist\SunSamples-Demos1.jar
nsicom-create-manifest:
do-jar-no-manifest:
update-jad:
Updating application descriptor: C:\MyProjects\SunSamples-Demos1\dist\SunSamples-Demos1.jad
Generated "C:\MyProjects\SunSamples-Demos1\dist\SunSamples-Demos1.jar" is 117361 bytes.
ricoh-init-dalp:
ricoh-add-app-icon:
ricoh-build-dalp-with-icon:
ricoh-build-dalp-without-icon:
ricoh-build-dalp:
savaje-prepare-icon:
savaje-build-jnlp:
post-jar:
jar:
pre-run:
cldc-run:
Copying 1 file to C:\MyProjects\SunSamples-Demos1\dist\nbrun49350
Copying 1 file to C:\MyProjects\SunSamples-Demos1\dist\nbrun49350
Jad URL for OTA execution:
http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/C%3A/MyProjects/SunSamples-Demos1/dist//SunSamples-Demos1.jad
Starting emulator in execution mode
ricoh-run:
semc-icon-assembly:
semc-ppro-emulator:
semc-do-run:
semc-run:
savaje-run:
nokiaS80-run:
nsicom-run:
run:
BUILD SUCCESSFUL (total time: 4 seconds)

As you can see above, there is no message in output about not found Java.
At the same time, I have installed Java using installer and don't think I need to fix the installation somehow. 
What I see is:
- I install Java SE with installer using all defaults it proposes;
- I install Netbeans with installer;
- I create MIDP sample and try to run it.

It doesn't work without any message which identifies the cause. This is the issue so I'm reopening it.
Comment 11 Petr Suchomel 2008-07-11 13:10:14 UTC
Thanks for this info. I wish I can get such information prior the others. This looks like there is for example firewall
problem which kills the process when it tries to get on net (WTK does this, not sure why, probably some XML schema). I
do not think it is related to Java except the Java you put on PATH had a different FW settings than the one WTK use.
Could you for your security disconnect from net, switch the firewall off and test this again?
Comment 12 Andrei Chistiakov 2008-07-11 13:21:34 UTC
Yes, of course but unfortunately with the same result.
Please find the new output in attachment, with firewall switched off.
Comment 13 Andrei Chistiakov 2008-07-11 13:22:37 UTC
Created attachment 64329 [details]
output
Comment 14 Petr Suchomel 2008-07-11 13:29:16 UTC
This is something weird - are you able to start emulator by hand, for example from command line with "emulator.exe
-version" Also what Ant says if you switch to verbose mode? This issue is definitely somewhere else, but I am not able
to identify what's wrong now.
Comment 15 Ivan Sidorkin 2008-07-11 13:36:33 UTC
C:\NetBeansDev65\mobility8\WTK2.5.2\bin>emulator.exe -version
Create process failed
Comment 16 Andrei Chistiakov 2008-07-11 13:44:54 UTC
Created attachment 64331 [details]
output in verbose mode
Comment 17 Petr Suchomel 2008-07-14 07:27:35 UTC
Just for my info, what version of Java do you use 32 or 64 bits?
Comment 18 Andrei Chistiakov 2008-07-14 10:48:32 UTC
32-bit
Comment 19 Petr Suchomel 2008-07-14 13:13:52 UTC
C:\Program Files\NetBeans Dev 200807100006\mobility8\WTK2.5.2\bin>emulator -version
Sun Java(TM) Wireless Toolkit 2.5.2 for CLDC
Profile: MIDP-2.1
Configuration: CLDC-1.1
Optional: J2ME-WS-1.0,J2ME-XMLRPC-1.0,JSR179-1.0.1,JSR180-1.0.1,JSR184-1.1,JSR21
1-1.0,JSR226-1.0,JSR229-1.1.0,JSR234-1.0,JSR238-1.0,JSR239-1.0,JSR75-1.0,JSR82-1
.1,MMAPI-1.1,SATSA-APDU-1.0,SATSA-CRYPTO-1.0,SATSA-JCRMI-1.0,SATSA-PKI-1.0,WMA-1
.1,WMA-2.0

Works for me.
Comment 20 Petr Suchomel 2008-07-14 13:17:02 UTC
Just tested same project with same build NetBeans IDE Dev (Build 200807100006).
Works for me. No idea what can be wrong in your case - could you bring some more (whatever else) information?
Comment 21 Andrei Chistiakov 2008-07-14 13:24:07 UTC
Just in case...
Petr, could you please execute 'echo %PATH%' on your machine and copy/paste the output here?
Comment 22 Andrei Chistiakov 2008-07-14 14:35:45 UTC
Petr, the situation is clarified.
When I install JDK, I usually do not install public JRE. JRE installer copies java.exe to Windows\System32 folder. If I
install JDK without public JRE, java.exe is not copied there. 
That's why you can execute java.exe and start emuilator while I can't. You most likely have installed public JRE and
have java.exe in C:\Windows\System32.
Comment 23 Petr Suchomel 2008-07-14 14:51:29 UTC
The %PATH% here:
F:\development\6_5\main>echo %PATH%
C:\Program Files\Common Files\ArcSoft\Bin;C:\Program Files\Common Files\Symbian\
tools;C:\Perl\bin\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Pr
ogram Files\Intel\Wireless\Bin\;"c:\Program Files\apache-ant-1.7.0\bin";C:\Progr
am Files\Subversion\bin;C:\Program Files\Mercurial;C:\Ericsson\SDS4.0\icp\window
s;F:\Symbian\UIQ3SDK\epoc32\tools\nokia_compiler\Symbian_Tools\Command_Line_Tool
s;C:\Program Files\VoiceAge\Common
Comment 24 Petr Suchomel 2008-07-14 14:53:15 UTC
OK, that explains a lot. Probably we can close this but mention this in Release Notes. I do not want to pass additional
path in env variable, because in such case I will override all user settings, with no escape
Comment 25 Petr Suchomel 2008-07-15 08:10:55 UTC
I am closing the bug as this is not primarily bug as is: the workaround is fairly easy adnd should be documented in
Release Notes:
- If Java was installed in specific fashion (no public JRE) you can set up your favourite JDK you want emulator to run
on by  putting java.exe binary on PATH 
- Update JDK to install public JRE
Comment 26 Bradley Schmidt 2008-07-15 17:01:43 UTC
We can add it to the release notes, but need to know the following for clarification:

- is this a Windows only issue? 

- Does it also impact Linux environments?

- Any impact on MacOS using Mpowerplayer?

- Does it only affect WTK users, or is it a problem for any Java ME platform the IDE launches to run an application?
Comment 27 Petr Suchomel 2008-07-15 17:07:21 UTC
- is this a Windows only issue? 
Yes

- Does it also impact Linux environments?
No

- Any impact on MacOS using Mpowerplayer?
No

- Does it only affect WTK users, or is it a problem for any Java ME platform the IDE launches to run an application?
Not any platform. There are list of likely affected ones: Sony Ericsson, Sprint emulators as far as based on WTK
architecture as well.
Comment 28 Ivan Sidorkin 2008-07-15 20:02:59 UTC
if it will be mentioned in relnotes it will be very good, but still will not solve bug.
lets clarify what bug we have here:
- NB was installed with bundled wtk
- created mobility project, pressed Run button
- BUILD SUCCESSFUL in output window and nothing happened (BTW, by default output window opened only in case of any
error, so if output window was not opened manually than Run action will visually do nothing )

Is it OK what Run do nothing? not a bug?

on linux user can see some message in output but still BUILD SUCCESSFUL 

what you can do:
 - pass java path to emulator (may be only for bundled wtk emulator)
or 
 - analyse emulator output and/or exit code and file build if exit code!=0
Comment 29 Petr Suchomel 2008-07-15 20:26:30 UTC
The strange things is, the emulator does not report error return code, if it would,it would fail. Passing JAVA path is
not a good idea, the user completely loses control in which environment is process running. This can have a undefined
side effects as well it is not compatible change.
Comment 30 Petr Suchomel 2008-07-15 20:31:24 UTC
May it is bug, but not the one NetBeans can fix:
            try
            {
                final int i = doExecute();
                if (i != 0)
                    throw new BuildException(Bundle.getMessage("ERR_RunFailed", String.valueOf(i))); // No I18N
            }
            catch (IOException ioe)
            {
                throw new BuildException(ioe);
            }
The task is correct, emulator simply reports it runs well :-(
Comment 31 Ivan Sidorkin 2008-07-16 00:45:55 UTC
in fact emulator returns 1
the problem is that you do not check it.

see mobility.antext/src/org/netbeans/mobility/antext/RunTask.java line 391

if you will change this line to "i = exec.execute();" it will fix this issue somehow, but I don't know how it will
affect rest part of this method. 

could you please investigate it.
Comment 32 Petr Suchomel 2008-07-16 15:00:30 UTC
I am just playing with no public JRE installed, seems this is one of the smaller problems. Visibly various SDK's depend
on public JRE in different manner, so the are failing themselves on various errors, can not be detected etc. Seems this
is mainly issue if:
1) Do not have public JRE
2) Installed NB from installer and have WTK added by it
In other cases, you will not be able run SDK's at all (complaining about missing keys in registry, java etc., more less
descriptive errors).
I can try to do something with Ant task, but probably better resolution will be to add check into installer, it'll help
to survive nightmare with running many other SDK in advance.
Comment 33 Bradley Schmidt 2008-10-27 15:00:57 UTC
This sounds like an FAQ should be written to explain that the public JRE is necessary for most Java ME emulators to
launch, including and especially the WTK that's bundled with NetBeans. IMO most users have default installations of the
JDK and are unlikely to experience this problem. This issue will also be in the release notes.
Comment 34 almubinsultan 2010-02-05 08:14:16 UTC
can any one help me for bellow problem

pre-init:
pre-load-properties:
exists.config.active:
exists.netbeans.user:
exists.user.properties.file:
load-properties:
exists.platform.active:
exists.platform.configuration:
exists.platform.profile:
basic-init:
cldc-pre-init:
cldc-init:
cdc-init:
ricoh-pre-init:
ricoh-init:
semc-pre-init:
semc-init:
savaje-pre-init:
savaje-init:
sjmc-pre-init:
sjmc-init:
cdc-hi-pre-init:
cdc-hi-init:
nokiaS80-pre-init:
nokiaS80-init:
nsicom-pre-init:
nsicom-init:
post-init:
init:
conditional-clean-init:
conditional-clean:
pre-clean:
clean-timestamp:
clean-preprocessed:
clean-classes:
clean-obfuscated:
clean-preverified:
clean-manifest:
clean-jar:
clean-jad:
clean-javadoc:
clean-j9:
clean-ricoh:
clean-semc:
clean-savaje:
clean-sjmc:
Deleting: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\convert854826716
post-clean:
do-clean:
deps-jar:
pre-preprocess:
do-preprocess:
Created dir: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\preprocessed
Pre-processing 1 file(s) into C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\preprocessed directory.
post-preprocess:
preprocess:
pre-compile:
extract-libs:
Created dir: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\compiled
do-compile:
Compiling 1 source file to C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\compiled
post-compile:
compile:
pre-obfuscate:
proguard-init:
skip-obfuscation:
proguard:
post-obfuscate:
obfuscate:
lwuit-build:
pre-preverify:
do-preverify:
Created dir: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\preverifysrc
Copying 1 file to C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\preverifysrc
Created dir: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\preverified
Preverifying 1 file(s) into C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\build\preverified directory.
post-preverify:
preverify:
pre-jar:
set-password-init:
set-keystore-password:
set-alias-password:
set-password:
create-jad:
Created dir: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist
add-configuration:
add-profile:
do-extra-libs:
Created dir: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist\lib
nokiaS80-prepare-j9:
nokiaS80-prepare-manifest:
nokiaS80-prepare-manifest-no-icon:
nokiaS80-create-manifest:
jad-jsr211-properties.check:
jad-jsr211-properties:
semc-build-j9:
do-jar:
Building jar: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist\MobileApplication3.jar
nsicom-create-manifest:
do-jar-no-manifest:
update-jad:
Updating application descriptor: C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist\MobileApplication3.jad
Generated "C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist\MobileApplication3.jar" is 2067 bytes.
ricoh-init-dalp:
ricoh-add-app-icon:
ricoh-build-dalp-with-icon:
ricoh-build-dalp-without-icon:
ricoh-build-dalp:
savaje-prepare-icon:
savaje-build-jnlp:
post-jar:
jar:
pre-run:
netmon.check:
open-netmon:
cldc-run:
Copying 1 file to C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist\nbrun8467388747756231332
Copying 1 file to C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\dist\nbrun8467388747756231332
Jad URL for OTA execution: http://localhost:8082/servlet/org.netbeans.modules.mobility.project.jam.JAMServlet/C%3A/Documents+and+Settings/mubin/My+Documents/NetBeansProjects/MobileApplication3/dist//MobileApplication3.jad
Starting emulator in execution mode
*** Error ***
Failed to connect to device 0!
Reason:
Emulator 0 terminated while waiting for it to register!
C:\Documents and Settings\mubin\My Documents\NetBeansProjects\MobileApplication3\nbproject\build-impl.xml:889: Execution failed with error code 1.
BUILD FAILED (total time: 35 seconds)
Comment 35 midani 2010-10-28 13:26:58 UTC
I am trying to run keystore command from the command prompt and also I am trying to run 

other commands. I am copying and pasting what happens when I do this.

Also, if I want to run something like a netstat command, I have to go all the way out to the c:\windows\system32 directory as follows:


C:\Documents and Settings\mismith>cd c:\windows\system32

C:\WINDOWS\system32>-laf javax.swing.plaf.metal.MetalLookAndFeel
'-laf' is not recognized as an internal or external command,
operable program or batch file.

C:\WINDOWS\system32>cd c:\

C:\>-laf javax.swing.plaf.metal.MetalLookAndFeel
'-laf' is not recognized as an internal or external command,
operable program or batch file.

I keep getting the 'keytool' or 'whatever' is not recognized as an internal or external command, operable program or batch file.

Does this mean that I am missing a JRE and need to install one? I am a newbie and would appreciate any help you can provide.

Thank you, Midani