Hello, I have 0 experience in the ways of java but recently had a script made for me in it.
Lets say for the sake of the thread that my computer cannot run java applications, rather requiring an executable of some sort.
Would anyone mind creating a simple .exe from this .java file?
Is such a thing even reasonable to expect? I have no idea of how complex this would be.
It obviously would not be the safest way, so I would greatly prefer the sourcecode of that executable to the actual .exe, but after waiting 6 months for this project to even get this far I can settle for less
Much obliged,
rf
Edit: wow, I forgot to attach the javascript.
Edit2: it isnt javascript :O
Code:
import java.io.*;
import java.util.Scanner;
import java.util.regex.MatchResult;
public class Converter
{
public static void main( String[] args )
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please make sure the file you wish to convert is in\nthe same directory as this program and enter the name:");
try
{
Converter.convert(new File(stdin.readLine()));
System.out.println("[Note: Any existing files may have been replaced.]");
}
catch (IOException ioex)
{
System.out.println("Conversion Failed!");
}
System.exit(0);
}
public static File convert( File input ) throws IOException
{
return(Converter.convertCleanedInput(Converter.cleanInput(input)));
}
private static File cleanInput( File inputToClean ) throws IOException
{
//Description: Cleans input file with the following format...
//
// pos#A" Saved: ( # # # ) #B #C ( # # # ) input (FLBR) : $VARIOUS server time : #D
// #A #B #C $VARIOUS #D
//
// If $VARIOUS is null, then it is replaced by a hyphen as a place holder.
File outFile = new File("CleanInput.rtf");
BufferedWriter out = new BufferedWriter(new FileWriter(outFile, false));
Scanner in = new Scanner(inputToClean);
//The following code obtains the pattern we wish to look for.
//Please do not edit it, as even the smallest change will cause the program to stop functioning properly.
in.findWithinHorizon("pos(\\S+)\"\\sSaved:\\s\\(\\s\\S*\\s\\S*\\s\\S*\\s\\)\\s(\\S*)\\s(\\S*)\\s\\(\\s\\S*\\s\\S*\\s\\S*\\s\\)\\sinput\\s\\(FLBR\\)\\s:\\s(\\S*\\s*\\S*\\s*\\S*\\s*\\S*)\\s*server\\stime\\s:\\s(\\S*)",0);
MatchResult result = null;
try
{
result = in.match();
}
catch (IllegalStateException ise)
{
return(outFile);
}
while (true)
{
//The following loop goes through each line that matches the pattern and puts it into a strict format.
for (int i = 1; i <= result.groupCount(); i++)
{
switch (i)
{
case 1://#A
case 2://#B
case 3://#C
out.write(result.group(i) + " ");
break;
case 4://$VARIOUS
out.write((result.group(i).length() == 0 ? "- " : result.group(i).replaceAll("\\s", "") + " "));
break;
case 5://#D
out.write(result.group(i));
break;
default://This case should never occur.
break;
}
}
out.newLine();
in.findWithinHorizon("pos(\\S+)\"\\sSaved:\\s\\(\\s\\S*\\s\\S*\\s\\S*\\s\\)\\s(\\S*)\\s(\\S*)\\s\\(\\s\\S*\\s\\S*\\s\\S*\\s\\)\\sinput\\s\\(FLBR\\)\\s:\\s(\\S*\\s*\\S*\\s*\\S*\\s*\\S*)\\s*server\\stime\\s:\\s(\\S*)",0);
try
{
result = in.match();
}
catch (IllegalStateException ise)
{
break;
}
}
out.close();
in.close();
System.out.println("Cleaned input file and saved as \"CleanInput.rtf\"");
return(outFile);
}
private static File convertCleanedInput( File cleanInput ) throws IOException
{
//Description: Converts cleaned line of input with the following format...
//
// #A #B #C $VARIOUS #D
// //#A//#D//;cl_pitchspeed #Pitch;cl_yawspeed #Yaw;$FBJCLRA
//
// #Pitch = Current #B * 125 - Previous #B * 125
// #Yaw = Current #C * 125 - Previous #C * 125
// $FBJCLRA is derived from {Various} based on which letters
// it contains, or subsequently, does not contain:
// F = +forward, no F = -forward
// B = +back, no B = -back
// J = +moveup, no J = -moveup
// C = +movedown, no C = -movedown
// L = +moveleft, no L = -moveleft
// R = +moveright, no R = -moveright
// A = +attack, no A = -attack
File outFile = new File("ConvertedInput.rtf");
BufferedWriter out = new BufferedWriter(new FileWriter(outFile, false));
Scanner in = new Scanner(cleanInput),
traversal = null;
double[][] pitchAndYaw = new double[2][2];
String[] convertedLine = new String[5];
while (in.hasNextLine())
{
traversal = new Scanner(in.nextLine());
convertedLine[0] = "//" + traversal.nextInt();
pitchAndYaw[0][0] = pitchAndYaw[1][0];
pitchAndYaw[0][1] = pitchAndYaw[1][1];
pitchAndYaw[1][0] = traversal.nextDouble();
pitchAndYaw[1][1] = traversal.nextDouble();
convertedLine[2] = "//;cl_pitchspeed " + ((pitchAndYaw[1][0] * 125) - (pitchAndYaw[0][0] * 125));
convertedLine[3] = ";cl_yawspeed " + ((pitchAndYaw[1][1] * 125) - (pitchAndYaw[0][1] * 125));
String FBJCLRA = traversal.next().toUpperCase();
convertedLine[1] = "//" + traversal.next();
convertedLine[4] = ";" + (FBJCLRA.contains("F") ? "+" : "-") + "forward;" +
(FBJCLRA.contains("B") ? "+" : "-") + "back;" +
(FBJCLRA.contains("J") ? "+" : "-") + "moveup;" +
(FBJCLRA.contains("C") ? "+" : "-") + "movedown;" +
(FBJCLRA.contains("L") ? "+" : "-") + "moveleft;" +
(FBJCLRA.contains("R") ? "+" : "-") + "moveright;" +
(FBJCLRA.contains("A") ? "+" : "-") + "attack;";
out.write(convertedLine[0] + convertedLine[1] + convertedLine[2] + convertedLine[3] + convertedLine[4]);
out.newLine();
}
out.close();
in.close();
System.out.println("Converted cleaned input file and saved as \"ConvertedInput.rtf\"");
return(outFile);
}
}