• Intro Headers Instructions Macros Commands
  • Fork me on GitHub
    • Introduction
    • How to install bnd
    • Guided Tour
    • Guided Tour Workspace & Projects
    • Concepts
    • Best practices
    • Build
    • Project Setup
    • Generating JARs
    • Versioning
    • Baselining
    • Service Components
    • Metatype
    • Contracts
    • Bundle Annotations
    • Accessor Properties
    • SPI Annotations
    • Resolving Dependencies
    • Launching
    • Startlevels
    • Testing
    • Testing with Launchpad
    • Packaging Applications
    • JPMS Libraries
    • Wrapping Libraries to OSGi Bundles
    • Generating Documentation
    • Commands
    • For Developers
    • Tips for Windows users
    • Tools bound to bnd
    • Headers
    • Instruction Reference
    • Instruction Index
    • Macro Reference
    • Macro Index
    • Plugins
    • External Plugins
    • Settings
    • Errors
    • Warnings
    • Frequently Asked Questions
  • -runenv PROPERTIES

    public Map<String,String> getRunEnv() {
    	String runenv = project.getProperty(Constants.RUNENV);
    	if ( runenv != null) {
    		return OSGiHeader.parseProperties(runenv);
    	}		
    	return Collections.emptyMap();
    }
    
    public int launch() throws Exception {
    	prepare();
    	java = new Command();
    	
    	
    	//
    	// Handle the environment
    	//
    	
    	Map<String,String> env = getRunEnv();
    	for ( Map.Entry<String,String> e:env.entrySet()) {
    		java.var(e.getKey(), e.getValue());
    	}
    	
    	java.add(project.getProperty("java", "java"));
    	String javaagent = project.getProperty(Constants.JAVAAGENT);
    	if (Processor.isTrue(javaagent)) {
    		for (String agent : agents) {
    			java.add("-javaagent:" + agent);
    		}
    	}
    
    	String jdb = getRunJdb();
    	if (jdb != null) {
    		int port = 1044;
    		try {
    			port = Integer.parseInt(project.getProperty(Constants.RUNJDB));
    		}
    		catch (Exception e) {
    			// ok, value can also be ok, or on, or true
    		}
    		String suspend = port > 0 ? "y" : "n";
    
    		java.add("-Xrunjdwp:server=y,transport=dt_socket,address=" + Math.abs(port) + ",suspend=" + suspend);
    	}
    	
    	java.add("-cp");
    	java.add(Processor.join(getClasspath(), File.pathSeparator));
    	java.addAll(getRunVM());
    	java.add(getMainTypeName());
    	java.addAll(getRunProgramArgs());
    	if (timeout != 0)
    		java.setTimeout(timeout + 1000, TimeUnit.MILLISECONDS);
    
    	File cwd = getCwd();
    	if (cwd != null)
    		java.setCwd(cwd);
    
    	project.trace("cmd line %s", java);
    	try {
    		int result = java.execute(System.in, System.err, System.err);
    		if (result == Integer.MIN_VALUE)
    			return TIMEDOUT;
    		reportResult(result);
    		return result;
    	}
    	finally {
    		cleanup();
    		listeners.clear();
    	}
    }
    
    • GitHub