diff --git a/.gitignore b/.gitignore
index f010781..302142a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
builds/Launcher.bat
+/.metadata/
diff --git a/robopipe/Launcher.bat b/robopipe/Launcher.bat
new file mode 100644
index 0000000..0a95ee2
--- /dev/null
+++ b/robopipe/Launcher.bat
@@ -0,0 +1,3 @@
+@echo off
+java -jar bin
+exit
diff --git a/robopipe/bin/.gitignore b/robopipe/bin/.gitignore
new file mode 100644
index 0000000..8da1aea
--- /dev/null
+++ b/robopipe/bin/.gitignore
@@ -0,0 +1,3 @@
+/.classpath
+/.project
+/robopipe/
diff --git a/robopipe/src/.classpath b/robopipe/src/.classpath
new file mode 100644
index 0000000..3f3893a
--- /dev/null
+++ b/robopipe/src/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/robopipe/src/.project b/robopipe/src/.project
new file mode 100644
index 0000000..0f6f6a7
--- /dev/null
+++ b/robopipe/src/.project
@@ -0,0 +1,17 @@
+
+
+ src
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/robopipe/src/robopipe/App.java b/robopipe/src/robopipe/App.java
index 7b1da35..3e9ffbb 100644
--- a/robopipe/src/robopipe/App.java
+++ b/robopipe/src/robopipe/App.java
@@ -4,9 +4,13 @@
*/
package robopipe;
+import java.awt.GraphicsEnvironment;
+import java.io.Console;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.PrintWriter;
import java.math.BigDecimal;
import java.net.ServerSocket;
import java.net.Socket;
@@ -18,6 +22,9 @@ import edu.wpi.first.networktables.NetworkTableInstance;
public class App {
+ ///TODO: Always remember to set to false before building
+ static boolean isEclipse = true;
+
NetworkTableEntry encoderEntry, navXEntry;
double encoder = 46.83583538, navX = 3.37583994;
ServerSocket serverSocket;
@@ -27,10 +34,31 @@ public class App {
InputStream in;
String output;
- public static void main( String[] args )
- {
- System.out.println("Robopipe Start");
- new App().run();
+ public static void main( String[] args )
+ {
+ // Thanks to Frezze98 bolalo on StackOverflow for the code to create a batch file
+ // to start the program in a command window
+ Console console = System.console();
+ if(console == null && !GraphicsEnvironment.isHeadless() && !isEclipse) {
+ String filename = new File(App.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getName();
+ try {
+ File batch = new File("Launcher.bat");
+ if(!batch.exists()){
+ batch.createNewFile();
+ PrintWriter writer = new PrintWriter(batch);
+ writer.println("@echo off");
+ writer.println("java -jar "+filename);
+ writer.println("exit");
+ writer.flush();
+ }
+ Runtime.getRuntime().exec("cmd /c start \"\" "+batch.getPath());
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ System.out.println("Robopipe Start");
+ new App().run();
+ }
}
public void run() {