How to keep the console window alive?

559 views
Skip to first unread message

Joshua Donnelly

unread,
Nov 9, 2013, 7:30:05 PM11/9/13
to ve...@googlegroups.com

from various places there's usually a way of keeping the console window alive:
cmd /k    #keepalive
python -i   #drop into interactive console afterwards  
C#  Console.ReadLine()  //waits for input therefore keeping the terminal open
node.js process.stdin.resume()

I wondered how to keep the vertx console window alive 
from the command line AND from inside a verticle??

so I'm looking at vertx.bat

and did 
echo "%JAVA_EXE%" %JVM_OPTS% %JMX_OPTS% %JAVA_OPTS% %VERTX_OPTS% %VERTX_MODULE_OPTS% -Djava.util.logging.config.file="%VERTX_JUL_CONFIG%" -Dvertx.home="%VERTX_HOME%" -Dvertx.clusterManagerFactory="%VERTX_CLUSTERMANAGERFACTORY%" -classpath "%CLASSPATH%" org.vertx.java.platform.impl.cli.Starter %CMD_LINE_ARGS%

where it builds a command like...

"C:\Program Files\Java\jdk1.8.0\/bin/java.exe"      -Djava.util.logging.config.file="C:\A\V\Vertx\bin\..\conf\logging.properties" -Dvertx.home="C:\A\V\Vertx\bin\.." -Dvertx.clusterManagerFactory="org.vertx.java.spi.cluster.impl.hazelcast.HazelcastClusterManagerFactory" -classpath ";C:\A\V\Vertx\bin\..\conf;C:\A\V\Vertx\bin\..\lib\*" org.vertx.java.platform.impl.cli.Starter version
2.1M1 (built 2013-10-29 11:11:22)
which I also prefixed with %comspec% /K && "C:\Program Files\Java\jdk1.8.0\/bin/java.exe"...
which did not work

further down in vertx.bat ...
rem Set variable VERTX_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if  not "" == "%VERTX_EXIT_CONSOLE%" exit 1
exit /b 1

suggests that cmd.exe is being used where /c is the switch just to exit
/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains
but the command produced seems to be calling java directly (but .bat is a cmd.exe process)
loaded up with some default -cp config. From there I can't see a java way of keeping the console open

maybe it's javaw.exe 
set JAVA_EXE=%JAVA_HOME%/bin/javaw.exe 
instead of 
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
(tried that, but that alone didn't change the behaviour of the console window)

so maybe I set Windows.Environment('PROCESS')('VERTX_EXIT_CONSOLE')=0 
or FALSE or False or false, but also without the desired result.

if you're already using at a bunch of environment variables, like
JAVA_OPTS;VERTX_OPTS;JVM_OPTS;JMX_OPTS;APP_BASE;VERTX_HOME;JAVA_HOME;JAVA_EXE;VERTX_MODS;VERTX_MODULE;VERTX_JUL;VERTX_CLUSTERMANAGERFACTORY;CMD_LINE;VERTX_EXIT
Windows.Environment('PROCESS')('JAVA_HOME')="C:\path to oracle or open JDK folder, version 7 or higher\"

maybe someone who knows what they are doing could add one like
Windows.Environment('PROCESS')('VERTX_KEEPCONSOLEALIVE')=1
which would have the desired result. Or maybe I didn't RTFM enough, since
in the main manual and the js manual I couldn't see any more info on console
except for an example using console.log -- which is the code I'm trying to
run ie. "C:/A/V/Vertx/bin/vertx.bat" "C:/hello.js"
 
______where hello.js is_________________
var console = require('vertx/console');
console.log("hello world!); 
___________________________________

not a good place to be stuck, and java may not be aware of the terminal it runs in

Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)
where options include:
    -d32	  use a 32-bit data model if available
    -d64	  use a 64-bit data model if available
    -server	  to select the "server" VM
                  The default VM is server.

    -cp 
    -classpath 
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D=
                  set a system property
    -verbose:[class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -no-jre-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:...|:]
    -enableassertions[:...|:]
                  enable assertions with specified granularity
    -da[:...|:]
    -disableassertions[:...|:]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:[=]
                  load native agent library , e.g. -agentlib:hprof
                  see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:[=]
                  load native agent library by full pathname
    -javaagent:[=]
                  load Java programming language agent, see java.lang.instrument
    -splash:
                  show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.

Jez P

unread,
Nov 10, 2013, 4:07:54 AM11/10/13
to ve...@googlegroups.com
I see all the output when I run from the command line on OS X and Linux, but you're talking Windows and it's a long time since I used Windows (and never used vert.x on Windows at all). Are you running by double clicking a batch file or something? I'd have thought if you run it from a command prompt, then the command prompt window would stay open anyway.

Maybe you just want to redirect standard output so your logging all goes to a file instead of the console?
Reply all
Reply to author
Forward
0 new messages