Results 1 to 2 of 2
  1. #1
    Webjoch is offline Member
    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Default Run a jar file in a java project

    I am running a minecraft server and want to build a GUI. So I open now the jar file with a .bat file with this command:

    Java Code:
    java -Xincgc -Xmx1024M -jar "%~dp0craftbukkit-0.0.1-snapshot.jar
    The output is:

    Java Code:
    146 recipes
    16 achievements
    16:29:15 [INFO] Starting minecraft server version Beta 1.5_02
    16:29:15 [INFO] Loading properties
    16:29:15 [INFO] Starting Minecraft server on 192.168.2.32:25565
    16:29:15 [WARNING] **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
    16:29:15 [WARNING] The server will make no attempt to authenticate usernames. Beware.
    16:29:15 [WARNING] While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any
    16:29:15 [WARNING] To change this, set "online-mode" to "true" in the server.settings file.
    16:29:15 [INFO] This server is running Craftbukkit version git-Bukkit-0.0.0-753-g34e310c-b803jnks (MC: 1.5_02)
    16:29:15 [INFO] Preparing level "webjoch"
    16:29:15 [INFO] Preparing start region
    Now I want to execute this jar file in an other java project. So I made this code:

    Java Code:
    import java.io.*;
    
    public class manageServer {
    	public static void main(String args[]) {
    	    try {
    	        Runtime rt = Runtime.getRuntime();
    	        Process pr = rt.exec("java -Xincgc -Xmx1024M -jar \"c:\\Users\\Jochem\\Documents\\Minecraft server\\craftbukkit-0.0.1-SNAPSHOT.jar\"");
    	    	//Process pr = rt.exec("c:\\helloworld.exe");
    	 
    			BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    			String line=null;
    			 
    			while((line=input.readLine()) != null) {
    				System.out.println(line);
    			}
    			 
    			 int exitVal = pr.waitFor();
    			 System.out.println("Exited with error code "+exitVal);
    		 } catch(Exception e) {
    		 	System.out.println(e.toString());
    			e.printStackTrace();
    		}
        }
    }
    The output is:

    146 recipes
    16 achievements
    >
    >
    >
    >
    >
    >
    >
    >
    And I can't join the server.

    So the question is, how can I run this jar file in another java project.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    Have you looked at the error stream to see if there are any error messages?

Similar Threads

  1. Upload File From my Project
    By buffon2009 in forum Networking
    Replies: 1
    Last Post: 02-18-2011, 09:12 AM
  2. How to use resource (.res) file in your java me project
    By Basit781 in forum CLDC and MIDP
    Replies: 3
    Last Post: 11-24-2010, 04:58 AM
  3. Replies: 0
    Last Post: 11-24-2009, 01:49 PM
  4. project is out of sync with file system?
    By anthrax in forum Threads and Synchronization
    Replies: 1
    Last Post: 03-04-2009, 05:19 PM
  5. Replies: 0
    Last Post: 02-11-2009, 09:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •