title: How to create a new core in solr using java code?
body: <p>I am new in solr and i want to create a new core in solr by using java code and i don't want create it by terminal and GUI of solr, this is code that i am using and i am using 6.2.1 version of solr,  please help me . thanx in advance.</p>
  
  <pre><code>           coreName="metademo";
            String solrDir = "/home/manish/Downloads/solr-6.2.1/server/solr/";
  
          String baseSolrUrl ="http://localhost:8983/solr/";
          CoreAdminRequest.Create create = new CoreAdminRequest.Create(); 
          create.setCoreName("metademo"); 
          create.setInstanceDir(solrDir +File.separator ); 
          SolrClient client2=new   HttpSolrClient.Builder(baseSolrUrl).build();
  
          create.setDataDir(solrDir + File.separator + coreName + File.separator + "data"); 
          HttpSolrServer solrServer1 = new HttpSolrServer(solrDir,client); 
          CoreAdminRequest.createCore(coreName, solrDir, client2);
          create.createCore(coreName, solrDir, client2);
          System.out.println("Created core with name: " + coreName); 
  </code></pre>