@@ -34,7 +34,7 @@ public static void main(String[] args) throws Exception {
3434 System .err .println ("are you sure ? -f not -f=file ! it not can use!" );
3535 }
3636 }
37-
37+
3838 for (String arg : args ) {
3939 if (arg .startsWith ("--" ) && arg .contains ("=" )) {
4040 String [] dim = arg .split ("=" );
@@ -61,7 +61,7 @@ public static void main(String[] args) throws Exception {
6161 String logPath = getOrCreateEnv (PREFIX + "log" , "log/jcoder.log" );
6262
6363 String home = getOrCreateEnv (PREFIX + "home" , new File (System .getProperty ("user.home" ), ".jcoder" ).getAbsolutePath ());
64-
64+
6565 int port = Integer .parseInt (getOrCreateEnv (PREFIX + "port" , "8080" ));
6666
6767 System .setProperty ("java.awt.headless" , "true" ); //support kaptcha
@@ -81,7 +81,7 @@ public static void main(String[] args) throws Exception {
8181 context .setTempDirectory (new File (jcoderHome , "tmp" ));
8282 context .setContextPath ("/" );
8383 context .setServer (server );
84-
84+
8585 context .setWelcomeFiles (new String [] { "Home.jsp" });
8686
8787 context .setExtraClasspath (new File (jcoderHome , "resource" ).getAbsolutePath ());
@@ -92,19 +92,21 @@ public static void main(String[] args) throws Exception {
9292 } else {
9393 context .setWar ("src/main/webapp" );
9494 }
95-
96- context .setInitParameter ("org.eclipse.jetty.servlet.DefaultServlet.useFileMappedBuffer" , "false" );
97-
98- HandlerList list = new HandlerList () ;
95+
96+ HandlerList list = new HandlerList ();
9997
10098 WebAppContext web = new WebAppContext (); //add a web site in jcoder
101-
99+
102100 web .setContextPath ("/web/" );
103-
104- web .setInitParameter ("org.eclipse.jetty.servlet.DefaultServlet.useFileMappedBuffer" , "false" );
105-
106- web .setWar (new File (jcoderHome ,"web" ).getAbsolutePath ());
107-
101+
102+ web .setWar (new File (jcoderHome , "web" ).getAbsolutePath ());
103+
104+ // Fix for Windows, so Jetty doesn't lock files
105+ if (System .getProperty ("os.name" ).toLowerCase ().contains ("windows" )) {
106+ context .setInitParameter ("org.eclipse.jetty.servlet.Default.useFileMappedBuffer" , "false" );
107+ web .setInitParameter ("org.eclipse.jetty.servlet.Default.useFileMappedBuffer" , "false" );
108+ }
109+
108110 list .addHandler (web );
109111
110112 list .addHandler (context );
0 commit comments