List of usage examples for java.io File pathSeparatorChar
char pathSeparatorChar
To view the source code for java.io File pathSeparatorChar.
Click Source Link
From source file:org.sonatype.mercury.mp3.delta.cli.DeltaManagerCli.java
private void initMavenHome(CommandLine cli, Monitor monitor) throws Exception { File curF = new File("."); File mvn = new File(curF, "bin/mvn" + (File.pathSeparatorChar == ';' ? ".bat" : "")); if (cli.hasOption(MAVEN_HOME)) { _mavenHome = cli.getOptionValue(MAVEN_HOME); } else if (mvn.exists()) _mavenHome = curF.getCanonicalPath(); if (_mavenHome == null) throw new Exception(LANG.getMessage("cli.no.maven.home", curF.getAbsolutePath(), MAVEN_HOME + "")); if (_showDetails) Util.say(LANG.getMessage("maven.home", _mavenHome), _monitor); }
From source file:org.gradle.api.tasks.compile.CompileOptions.java
/** * Sets the bootstrap classpath to be used for the compiler process. Defaults to {@code null}. * * @deprecated Use {@link #setBootstrapClasspath(FileCollection)} instead. *///from www. j a v a2 s .c o m @Deprecated public void setBootClasspath(String bootClasspath) { DeprecationLogger.nagUserOfReplacedProperty("CompileOptions.bootClasspath", "CompileOptions.bootstrapClasspath"); if (bootClasspath == null) { this.bootstrapClasspath = null; } else { String[] paths = StringUtils.split(bootClasspath, File.pathSeparatorChar); List<File> files = Lists.newArrayListWithCapacity(paths.length); for (String path : paths) { files.add(new File(path)); } this.bootstrapClasspath = new SimpleFileCollection(files); } }
From source file:functionaltests.RestFuncTHelper.java
private static String getClassPath() throws Exception { return (getRmHome() + File.separator + "dist" + File.separator + "lib" + File.separator + "*") + File.pathSeparatorChar + getRmHome() + File.separator + "addons" + File.separator + "*" + File.pathSeparatorChar + System.getProperty("java.class.path"); }
From source file:org.jenkinsci.remoting.engine.HandlerLoopbackLoadStress.java
public HandlerLoopbackLoadStress(Config config) throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, UnrecoverableKeyException, KeyManagementException, OperatorCreationException { this.config = config; KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA"); gen.initialize(2048); // maximum supported by JVM with export restrictions keyPair = gen.generateKeyPair();/*from ww w . jav a2 s . co m*/ Date now = new Date(); Date firstDate = new Date(now.getTime() + TimeUnit.DAYS.toMillis(10)); Date lastDate = new Date(now.getTime() + TimeUnit.DAYS.toMillis(-10)); SubjectPublicKeyInfo subjectPublicKeyInfo = SubjectPublicKeyInfo .getInstance(keyPair.getPublic().getEncoded()); X500NameBuilder nameBuilder = new X500NameBuilder(BCStyle.INSTANCE); X500Name subject = nameBuilder.addRDN(BCStyle.CN, getClass().getSimpleName()).addRDN(BCStyle.C, "US") .build(); X509v3CertificateBuilder certGen = new X509v3CertificateBuilder(subject, BigInteger.ONE, firstDate, lastDate, subject, subjectPublicKeyInfo); JcaX509ExtensionUtils instance = new JcaX509ExtensionUtils(); certGen.addExtension(X509Extension.subjectKeyIdentifier, false, instance.createSubjectKeyIdentifier(subjectPublicKeyInfo)); ContentSigner signer = new JcaContentSignerBuilder("SHA1withRSA").setProvider(BOUNCY_CASTLE_PROVIDER) .build(keyPair.getPrivate()); certificate = new JcaX509CertificateConverter().setProvider(BOUNCY_CASTLE_PROVIDER) .getCertificate(certGen.build(signer)); char[] password = "password".toCharArray(); KeyStore store = KeyStore.getInstance("jks"); store.load(null, password); store.setKeyEntry("alias", keyPair.getPrivate(), password, new Certificate[] { certificate }); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(store, password); context = SSLContext.getInstance("TLS"); context.init(kmf.getKeyManagers(), new TrustManager[] { new BlindTrustX509ExtendedTrustManager() }, null); mainHub = IOHub.create(executorService); // on windows there is a bug whereby you cannot mix ServerSockets and Sockets on the same selector acceptorHub = File.pathSeparatorChar == 59 ? IOHub.create(executorService) : mainHub; legacyHub = new NioChannelHub(executorService); executorService.submit(legacyHub); serverSocketChannel = ServerSocketChannel.open(); JnlpProtocolHandler handler = null; for (JnlpProtocolHandler h : new JnlpProtocolHandlerFactory(executorService).withNioChannelHub(legacyHub) .withIOHub(mainHub).withSSLContext(context).withPreferNonBlockingIO(!config.bio) .withClientDatabase(new JnlpClientDatabase() { @Override public boolean exists(String clientName) { return true; } @Override public String getSecretOf(@Nonnull String clientName) { return secretFor(clientName); } }).withSSLClientAuthRequired(false).handlers()) { if (config.name.equals(h.getName())) { handler = h; break; } } if (handler == null) { throw new RuntimeException("Unknown handler: " + config.name); } this.handler = handler; acceptor = new Acceptor(serverSocketChannel); runtimeMXBean = ManagementFactory.getRuntimeMXBean(); operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean(); _getProcessCpuTime = _getProcessCpuTime(operatingSystemMXBean); garbageCollectorMXBeans = new ArrayList<GarbageCollectorMXBean>( ManagementFactory.getGarbageCollectorMXBeans()); Collections.sort(garbageCollectorMXBeans, new Comparator<GarbageCollectorMXBean>() { @Override public int compare(GarbageCollectorMXBean o1, GarbageCollectorMXBean o2) { return o1.getName().compareTo(o2.getName()); } }); stats = new Stats(); }
From source file:org.broadinstitute.gatk.tools.CatVariantsIntegrationTest.java
@Test(dataProvider = "MismatchedExtensionsTest", expectedExceptions = IOException.class) public void testMismatchedExtensions1(final String extension1, final String extension2) throws IOException { String cmdLine = String.format("java -cp \"%s\" %s -R %s -V %s -V %s -out %s", StringUtils.join(RuntimeUtils.getAbsoluteClassPaths(), File.pathSeparatorChar), CatVariants.class.getCanonicalName(), BaseTest.b37KGReference, new File(CatVariantsDir, "CatVariantsTest1" + extension1), new File(CatVariantsDir, "CatVariantsTest2" + extension2), BaseTest.createTempFile("CatVariantsTest", ".bcf")); ProcessController pc = ProcessController.getThreadLocal(); ProcessSettings ps = new ProcessSettings(Utils.escapeExpressions(cmdLine)); pc.execAndCheck(ps);//from w w w. j a v a 2 s . c o m }
From source file:com.toy.Client.java
/** * Start a new Application Master and deploy the web application on 2 Tomcat containers * * @throws Exception/*from w ww . ja v a 2s .c o m*/ */ void start() throws Exception { //Check tomcat dir final File tomcatHomeDir = new File(toyConfig.tomcat); final File tomcatLibraries = new File(tomcatHomeDir, "lib"); final File tomcatBinaries = new File(tomcatHomeDir, "bin"); Preconditions.checkState(tomcatLibraries.isDirectory(), tomcatLibraries.getAbsolutePath() + " does not exist"); //Check war file final File warFile = new File(toyConfig.war); Preconditions.checkState(warFile.isFile(), warFile.getAbsolutePath() + " does not exist"); yarn = YarnClient.createYarnClient(); yarn.init(configuration); yarn.start(); YarnClientApplication yarnApplication = yarn.createApplication(); GetNewApplicationResponse newApplication = yarnApplication.getNewApplicationResponse(); appId = newApplication.getApplicationId(); ApplicationSubmissionContext appContext = yarnApplication.getApplicationSubmissionContext(); appContext.setApplicationName("Tomcat : " + tomcatHomeDir.getName() + "\n War : " + warFile.getName()); // Set up the container launch context for the application master ContainerLaunchContext amContainer = Records.newRecord(ContainerLaunchContext.class); // Register required libraries Map<String, LocalResource> localResources = new HashMap<>(); FileSystem fs = FileSystem.get(configuration); uploadDepAndRegister(localResources, appId, fs, "lib-ext/curator-client-2.3.0.jar"); uploadDepAndRegister(localResources, appId, fs, "lib-ext/curator-framework-2.3.0.jar"); uploadDepAndRegister(localResources, appId, fs, "lib-ext/curator-recipes-2.3.0.jar"); // Register application master jar registerLocalResource(localResources, appId, fs, new Path(appMasterJar)); // Register the WAR that will be deployed on Tomcat registerLocalResource(localResources, appId, fs, new Path(warFile.getAbsolutePath())); // Register Tomcat libraries for (File lib : tomcatLibraries.listFiles()) { registerLocalResource(localResources, appId, fs, new Path(lib.getAbsolutePath())); } File juli = new File(tomcatBinaries, "tomcat-juli.jar"); if (juli.exists()) { registerLocalResource(localResources, appId, fs, new Path(juli.getAbsolutePath())); } amContainer.setLocalResources(localResources); // Setup master environment Map<String, String> env = new HashMap<>(); final String TOMCAT_LIBS = fs.getHomeDirectory() + "/" + Constants.TOY_PREFIX + appId.toString(); env.put(Constants.TOMCAT_LIBS, TOMCAT_LIBS); if (toyConfig.zookeeper != null) { env.put(Constants.ZOOKEEPER_QUORUM, toyConfig.zookeeper); } else { env.put(Constants.ZOOKEEPER_QUORUM, NetUtils.getHostname()); } // 1. Compute classpath StringBuilder classPathEnv = new StringBuilder(ApplicationConstants.Environment.CLASSPATH.$()) .append(File.pathSeparatorChar).append("./*"); for (String c : configuration.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) { classPathEnv.append(File.pathSeparatorChar); classPathEnv.append(c.trim()); } classPathEnv.append(File.pathSeparatorChar).append("./log4j.properties"); // add the runtime classpath needed for tests to work if (configuration.getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)) { classPathEnv.append(':'); classPathEnv.append(System.getProperty("java.class.path")); } env.put("CLASSPATH", classPathEnv.toString()); env.put(Constants.WAR, warFile.getName()); // For unit test with YarnMiniCluster env.put(YarnConfiguration.RM_SCHEDULER_ADDRESS, configuration.get(YarnConfiguration.RM_SCHEDULER_ADDRESS)); amContainer.setEnvironment(env); // 1.2 Set constraint for the app master Resource capability = Records.newRecord(Resource.class); capability.setMemory(32); appContext.setResource(capability); // 2. Compute app master cmd line Vector<CharSequence> vargs = new Vector<>(10); // Set java executable command vargs.add(ApplicationConstants.Environment.JAVA_HOME.$() + "/bin/java"); // Set Xmx based on am memory size vargs.add("-Xmx32m"); // Set class name vargs.add(TOYMaster.class.getCanonicalName()); vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stdout"); vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stderr"); StringBuilder command = new StringBuilder(); for (CharSequence str : vargs) { command.append(str).append(" "); } LOG.info("Completed setting up app master command " + command.toString()); List<String> commands = new ArrayList<>(); commands.add(command.toString()); amContainer.setCommands(commands); appContext.setAMContainerSpec(amContainer); // 3. Setup security tokens if (UserGroupInformation.isSecurityEnabled()) { Credentials credentials = new Credentials(); String tokenRenewer = configuration.get(YarnConfiguration.RM_PRINCIPAL); if (tokenRenewer == null || tokenRenewer.length() == 0) { throw new Exception("Can't get Master Kerberos principal for the RM to use as renewer"); } // For now, only getting tokens for the default file-system. final org.apache.hadoop.security.token.Token<?> tokens[] = fs.addDelegationTokens(tokenRenewer, credentials); if (tokens != null) { for (org.apache.hadoop.security.token.Token<?> token : tokens) { LOG.info("Got dt for " + fs.getUri() + "; " + token); } } DataOutputBuffer dob = new DataOutputBuffer(); credentials.writeTokenStorageToStream(dob); ByteBuffer fsTokens = ByteBuffer.wrap(dob.getData(), 0, dob.getLength()); amContainer.setTokens(fsTokens); } appContext.setQueue("default"); LOG.info("Submitting TOY application {} to ASM", appId.toString()); yarn.submitApplication(appContext); // Monitor the application and exit if it is RUNNING monitorApplication(appId); }
From source file:org.jboss.shrinkwrap.resolver.impl.maven.aether.ClasspathWorkspaceReader.java
private Set<String> getClassPathEntries(final String classPath) { if (Validate.isNullOrEmpty(classPath)) { return Collections.emptySet(); }/*ww w . jav a2 s . com*/ return new LinkedHashSet<String>(Arrays.asList(classPath.split(String.valueOf(File.pathSeparatorChar)))); }
From source file:com.twosigma.beaker.groovy.evaluator.GroovyEvaluator.java
protected GroovyClassLoader newEvaluator() throws MalformedURLException { try {// w w w . jav a2 s.c om Class.forName("org.codehaus.groovy.control.customizers.ImportCustomizer"); } catch (ClassNotFoundException e1) { String gjp = System.getenv(GROOVY_JAR_PATH); String errorMsg = null; if (gjp != null && !gjp.isEmpty()) { errorMsg = "Groovy libary not found, GROOVY_JAR_PATH = " + gjp; } else { errorMsg = "Default groovy libary not found. No GROOVY_JAR_PATH variable set."; } throw new GroovyNotFoundException(errorMsg); } ImportCustomizer icz = new ImportCustomizer(); if (!imports.isEmpty()) { for (String importLine : imports) { if (importLine.startsWith(STATIC_WORD_WITH_SPACE)) { String pureImport = importLine.replace(STATIC_WORD_WITH_SPACE, StringUtils.EMPTY) .replace(DOT_STAR_POSTFIX, StringUtils.EMPTY); if (importLine.endsWith(DOT_STAR_POSTFIX)) { icz.addStaticStars(pureImport); } else { int index = pureImport.lastIndexOf('.'); if (index == -1) { continue; } icz.addStaticImport(pureImport.substring(0, index), pureImport.substring(index + 1)); } } else { if (importLine.endsWith(DOT_STAR_POSTFIX)) { icz.addStarImports(importLine.replace(DOT_STAR_POSTFIX, StringUtils.EMPTY)); } else { icz.addImports(importLine); } } } } CompilerConfiguration config = new CompilerConfiguration().addCompilationCustomizers(icz); String acloader_cp = ""; for (int i = 0; i < classPath.size(); i++) { acloader_cp += classPath.get(i); acloader_cp += File.pathSeparatorChar; } acloader_cp += outDir; config.setClasspath(acloader_cp); compilerConfiguration = config; scriptBinding = new Binding(); return new GroovyClassLoader(newClassLoader(), compilerConfiguration); }
From source file:org.apache.helix.provisioning.yarn.YarnProvisioner.java
private ContainerLaunchContext createLaunchContext(ContainerId containerId, Container container, Participant participant) throws Exception { ContainerLaunchContext participantContainer = Records.newRecord(ContainerLaunchContext.class); // Map<String, String> envs = System.getenv(); String appName = applicationMasterConfig.getAppName(); int appId = applicationMasterConfig.getAppId(); String serviceName = _resourceConfig.getId().stringify(); String serviceClasspath = applicationMasterConfig.getClassPath(serviceName); String mainClass = applicationMasterConfig.getMainClass(serviceName); String zkAddress = applicationMasterConfig.getZKAddress(); // set the localresources needed to launch container Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(); LocalResource servicePackageResource = Records.newRecord(LocalResource.class); YarnConfiguration conf = new YarnConfiguration(); FileSystem fs;/*from ww w . j a v a 2 s . co m*/ fs = FileSystem.get(conf); String pathSuffix = appName + "/" + appId + "/" + serviceName + ".tar"; Path dst = new Path(fs.getHomeDirectory(), pathSuffix); FileStatus destStatus = fs.getFileStatus(dst); // Set the type of resource - file or archive // archives are untarred at destination // we don't need the jar file to be untarred for now servicePackageResource.setType(LocalResourceType.ARCHIVE); // Set visibility of the resource // Setting to most private option servicePackageResource.setVisibility(LocalResourceVisibility.APPLICATION); // Set the resource to be copied over servicePackageResource.setResource(ConverterUtils.getYarnUrlFromPath(dst)); // Set timestamp and length of file so that the framework // can do basic sanity checks for the local resource // after it has been copied over to ensure it is the same // resource the client intended to use with the application servicePackageResource.setTimestamp(destStatus.getModificationTime()); servicePackageResource.setSize(destStatus.getLen()); LOG.info("Setting local resource:" + servicePackageResource + " for service" + serviceName); localResources.put(serviceName, servicePackageResource); // Set local resource info into app master container launch context participantContainer.setLocalResources(localResources); // Set the necessary security tokens as needed // amContainer.setContainerTokens(containerToken); // Set the env variables to be setup in the env where the application master will be run LOG.info("Set the environment for the application master"); Map<String, String> env = new HashMap<String, String>(); env.put(serviceName, dst.getName()); // Add AppMaster.jar location to classpath // At some point we should not be required to add // the hadoop specific classpaths to the env. // It should be provided out of the box. // For now setting all required classpaths including // the classpath to "." for the application jar StringBuilder classPathEnv = new StringBuilder(Environment.CLASSPATH.$()).append(File.pathSeparatorChar) .append("./*"); classPathEnv.append(File.pathSeparatorChar); classPathEnv.append(serviceClasspath); for (String c : conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH, YarnConfiguration.DEFAULT_YARN_APPLICATION_CLASSPATH)) { classPathEnv.append(File.pathSeparatorChar); classPathEnv.append(c.trim()); } classPathEnv.append(File.pathSeparatorChar).append("./log4j.properties"); LOG.info("Setting classpath for service:\n" + classPathEnv.toString()); env.put("CLASSPATH", classPathEnv.toString()); participantContainer.setEnvironment(env); if (applicationMaster.allTokens != null) { LOG.info("Setting tokens: " + applicationMaster.allTokens); participantContainer.setTokens(applicationMaster.allTokens); } // Set the necessary command to execute the application master Vector<CharSequence> vargs = new Vector<CharSequence>(30); // Set java executable command LOG.info("Setting up app master command"); vargs.add(Environment.JAVA_HOME.$() + "/bin/java"); // Set Xmx based on am memory size vargs.add("-Xmx" + 4096 + "m"); // Set class name vargs.add(ParticipantLauncher.class.getCanonicalName()); // Set params for container participant vargs.add("--zkAddress " + zkAddress); vargs.add("--cluster " + appName); vargs.add("--participantId " + participant.getId().stringify()); vargs.add("--participantClass " + mainClass); vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/ContainerParticipant.stdout"); vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/ContainerParticipant.stderr"); // Get final commmand StringBuilder command = new StringBuilder(); for (CharSequence str : vargs) { command.append(str).append(" "); } LOG.info("Completed setting up container launch command " + command.toString() + " with arguments \n" + vargs); List<String> commands = new ArrayList<String>(); commands.add(command.toString()); participantContainer.setCommands(commands); return participantContainer; }