diff --git a/build.xml b/build.xml
index 60ec8b22f..89bcfb390 100644
--- a/build.xml
+++ b/build.xml
@@ -559,7 +559,6 @@
-
diff --git a/resources/ffdec b/resources/ffdec
index 412385cb6..9d469dca4 100644
--- a/resources/ffdec
+++ b/resources/ffdec
@@ -1,17 +1,5 @@
#!/usr/bin/env bash
-# This is a comment, it starts with "#".
-
-# Uncomment following and set it to higher value if you want more memory
-# You need 64 bit OS and 64 bit java to set it to higher values
-# FFDEC_MEMORY=1024m
-
-# Uncomment following when you encounter StackOverFlowErrors.
-# If the app then terminates with OutOfMemory you can experiment with lower value.
-# FFDEC_STACK_SIZE=32m
-
-# Hide VLC error output
-export VLC_VERBOSE=-1
export FFDEC_JARFILENAME=ffdec.jar
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
-exec $SCRIPT_DIR/run-java.sh "$@"
+exec $SCRIPT_DIR/ffdec.sh "$@"
diff --git a/resources/ffdec-cli b/resources/ffdec-cli
deleted file mode 100644
index 34fdbadda..000000000
--- a/resources/ffdec-cli
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/env bash
-
-# This is a comment, it starts with "#".
-
-# Uncomment following and set it to higher value if you want more memory
-# You need 64 bit OS and 64 bit java to set it to higher values
-# FFDEC_MEMORY=1024m
-
-# Uncomment following when you encounter StackOverFlowErrors.
-# If the app then terminates with OutOfMemory you can experiment with lower value.
-# FFDEC_STACK_SIZE=32m
-
-# Hide VLC error output
-export VLC_VERBOSE=-1
-export FFDEC_JARFILENAME=ffdec-cli.jar
-SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
-exec $SCRIPT_DIR/run-java.sh "$@"
diff --git a/resources/ffdec-cli.bat b/resources/ffdec-cli.bat
deleted file mode 100644
index 324592e90..000000000
--- a/resources/ffdec-cli.bat
+++ /dev/null
@@ -1,21 +0,0 @@
-@echo off
-rem This is a comment, it starts with "rem".
-
-rem Uncomment following and set it to higher value if you want more memory:
-rem You need 64 bit OS and 64 bit java to set it to higher values
-rem set FFDEC_MEMORY=1024m
-
-rem Uncomment following when you encounter StackOverFlowErrors.
-rem If the app then terminates with OutOfMemory you can experiment with lower value.
-rem set FFDEC_STACK_SIZE=32m
-
-rem Hide VLC error output
-set VLC_VERBOSE=-1
-
-if "%FFDEC_MEMORY%"=="" set FFDEC_MEMORY=1024m
-set STACK_SIZE_PARAM=
-set MEMORY_PARAM=
-if not "%FFDEC_STACK_SiZE%"=="" set STACK_SIZE_PARAM= -Xss%FFDEC_STACK_SiZE%
-if not "%FFDEC_MEMORY%"=="" set MEMORY_PARAM=-Xmx%FFDEC_MEMORY%
-
-java %MEMORY_PARAM%%STACK_SIZE_PARAM%-Djna.nosys=true -jar "%~dp0\ffdec-cli.jar" %*
diff --git a/resources/ffdec.bat b/resources/ffdec.bat
index 49202d76a..4f5956d49 100644
--- a/resources/ffdec.bat
+++ b/resources/ffdec.bat
@@ -19,4 +19,4 @@ set MEMORY_PARAM=
if not "%FFDEC_STACK_SiZE%"=="" set STACK_SIZE_PARAM= -Xss%FFDEC_STACK_SiZE%
if not "%FFDEC_MEMORY%"=="" set MEMORY_PARAM=-Xmx%FFDEC_MEMORY%
-java %MEMORY_PARAM%%STACK_SIZE_PARAM%-Djna.nosys=true -jar "%~dp0\ffdec.jar" %*
\ No newline at end of file
+java %MEMORY_PARAM%%STACK_SIZE_PARAM%-Djna.nosys=true -jar "%~dp0\ffdec.jar" %*
diff --git a/resources/ffdec.sh b/resources/ffdec.sh
index 412385cb6..f2406c8a2 100644
--- a/resources/ffdec.sh
+++ b/resources/ffdec.sh
@@ -10,8 +10,127 @@
# If the app then terminates with OutOfMemory you can experiment with lower value.
# FFDEC_STACK_SIZE=32m
+
# Hide VLC error output
export VLC_VERBOSE=-1
-export FFDEC_JARFILENAME=ffdec.jar
-SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
-exec $SCRIPT_DIR/run-java.sh "$@"
+
+# FFDec requires Oracle Java 8
+# Look for java in these directories
+LOOKUP_JRE_DIRS="/usr/lib/jvm/* /opt/java* /opt/jre*"
+# Required version
+REQ_JVER1=1
+REQ_JVER2=8
+REQ_JVER3=0
+REQ_JVER4=0
+
+
+if [ -z ${FFDEC_JARFILENAME+x} ]; then
+ FFDEC_JARFILENAME=ffdec.jar
+fi
+
+search_jar_file() {
+ JAR_FILE_CANDIDATES="./${FFDEC_JARFILENAME} ../dist/${FFDEC_JARFILENAME} /usr/share/java/${FFDEC_JARFILENAME} /usr/share/java/ffdec/${FFDEC_JARFILENAME} /usr/share/java/jpexs-decompiler/${FFDEC_JARFILENAME}"
+ for f in $JAR_FILE_CANDIDATES ; do
+ [ -r "$f" ] && JAR_FILE="$f" && return 0
+ done
+ echo Unable to find ${FFDEC_JARFILE} in the following locations:
+ echo "${JAR_FILE_CANDIDATES// /$'\n'}"
+ return 1
+}
+
+check_java_version () {
+ JVER1=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "\([0-9]*\)\.[0-9]*\.[0-9]*\(_[0-9]*\)\?".*/\1/')
+ JVER2=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.\([0-9]*\)\.[0-9]*\(_[0-9]*\)\?".*/\1/')
+ JVER3=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.[0-9]*\.\([0-9]*\)\(_[0-9]*\)\?".*/\1/')
+ JVER4=$(echo $JAVA_VERSION_OUTPUT | sed 's/java version "[0-9]*\.[0-9]*\.[0-9]*\(_\([0-9]*\)\)\?".*/\2/' | sed 's/^$/0/')
+
+ if [ "$JVER1" -gt $REQ_JVER1 ]; then
+ return 0
+ elif [ "$JVER1" -lt $REQ_JVER1 ]; then
+ return 1
+ fi
+
+ if [ "$JVER2" -gt $REQ_JVER2 ]; then
+ return 0
+ elif [ "$JVER2" -lt $REQ_JVER2 ]; then
+ return 1
+ fi
+
+ if [ "$JVER3" -gt $REQ_JVER3 ]; then
+ return 0
+ elif [ "$JVER3" -lt $REQ_JVER3 ]; then
+ return 1
+ fi
+
+ if [ "$JVER4" -lt $REQ_JVER4 ]; then
+ return 1
+ fi
+
+ return 0
+}
+
+# Handle symlinks
+PROGRAM="$0"
+while [ -L "$PROGRAM" ]; do
+ PROGRAM=$(readlink -f "$PROGRAM")
+done
+pushd "$(dirname "$PROGRAM")" > /dev/null
+
+search_jar_file || exit 1
+
+if [ "${JAR_FILE:0:1}" != '/' ] ; then
+ JAR_FILE=$(pwd)/$JAR_FILE
+fi
+
+popd > /dev/null
+
+if [ -z ${FFDEC_MEMORY+x} ]; then
+ FFDEC_MEMORY=1024m
+fi
+
+STACK_SIZE_PARAM=""
+MEMORY_PARAM=""
+if [ -n "$FFDEC_STACK_SIZE" ]; then
+ STACK_SIZE_PARAM=" -Xss$FFDEC_STACK_SIZE"
+fi
+if [ -n "$FFDEC_MEMORY" ]; then
+ MEMORY_PARAM=" -Xmx$FFDEC_MEMORY"
+fi
+
+args=(-Djava.net.preferIPv4Stack=true${MEMORY_PARAM}${STACK_SIZE_PARAM} -jar $JAR_FILE "$@")
+
+if [ "$(uname)" = "Darwin" ]; then
+ args=(-Xdock:name=FFDec -Xdock:icon=icon.png "${args[@]}")
+fi
+
+# Check default java
+if [ -x "$(which java)" ]; then
+ JAVA_VERSION_OUTPUT=$(java -version 2>&1)
+ JAVA_VERSION_OUTPUT=$(echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/')
+ check_java_version && exec java "${args[@]}"
+fi
+
+# Test other possible Java locations
+for JRE_PATH in $LOOKUP_JRE_DIRS; do
+ if [ -x "$JRE_PATH/bin/java" ]; then
+ JAVA_VERSION_OUTPUT=$("$JRE_PATH/bin/java" -version 2>&1)
+ JAVA_VERSION_OUTPUT=`echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/'`
+ check_java_version && {
+ export JRE_PATH
+ exec "$JRE_PATH/bin/java" "${args[@]}"
+ }
+ fi
+done
+
+# Failed
+if [ -x "$(which xmessage)" ]; then
+ xmessage -nearmouse -file - < /dev/null
-
-search_jar_file || exit 1
-
-if [ "${JAR_FILE:0:1}" != '/' ] ; then
- JAR_FILE=$(pwd)/$JAR_FILE
-fi
-
-popd > /dev/null
-
-if [ -z ${FFDEC_MEMORY+x} ]; then
- FFDEC_MEMORY=1024m
-fi
-
-STACK_SIZE_PARAM=""
-MEMORY_PARAM=""
-if [ -n "$FFDEC_STACK_SIZE" ]; then
- STACK_SIZE_PARAM=" -Xss$FFDEC_STACK_SIZE"
-fi
-if [ -n "$FFDEC_MEMORY" ]; then
- MEMORY_PARAM=" -Xmx$FFDEC_MEMORY"
-fi
-
-args=(-Djava.net.preferIPv4Stack=true${MEMORY_PARAM}${STACK_SIZE_PARAM} -jar $JAR_FILE "$@")
-
-if [ "$(uname)" = "Darwin" ]; then
- args=(-Xdock:name=FFDec -Xdock:icon=icon.png "${args[@]}")
-fi
-
-# Check default java
-if [ -x "$(which java)" ]; then
- JAVA_VERSION_OUTPUT=$(java -version 2>&1)
- JAVA_VERSION_OUTPUT=$(echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/')
- check_java_version && exec java "${args[@]}"
-fi
-
-# Test other possible Java locations
-for JRE_PATH in $LOOKUP_JRE_DIRS; do
- if [ -x "$JRE_PATH/bin/java" ]; then
- JAVA_VERSION_OUTPUT=$("$JRE_PATH/bin/java" -version 2>&1)
- JAVA_VERSION_OUTPUT=`echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/'`
- check_java_version && {
- export JRE_PATH
- exec "$JRE_PATH/bin/java" "${args[@]}"
- }
- fi
-done
-
-# Failed
-if [ -x "$(which xmessage)" ]; then
- xmessage -nearmouse -file - < /dev/null
-
-search_jar_file || exit 1
-
-if [ ${JAR_FILE:0:1} != '/' ] ; then
- JAR_FILE=`pwd`/$JAR_FILE
-fi
-
-popd > /dev/null
-
-args=(-jar $JAR_FILE -translator)
-
-if [ "`uname`" = "Darwin" ]; then
- args=(-Xdock:name=FFDec -Xdock:icon=icon.png "${args[@]}")
-fi
-
-# Check default java
-if [ -x "`which java`" ]; then
- JAVA_VERSION_OUTPUT=`java -version 2>&1`
- JAVA_VERSION_OUTPUT=`echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/'`
- check_java_version && exec java "${args[@]}"
-fi
-
-# Test other possible Java locations
-for JRE_PATH in $LOOKUP_JRE_DIRS; do
- if [ -x "$JRE_PATH/bin/java" ]; then
- JAVA_VERSION_OUTPUT=`"$JRE_PATH/bin/java" -version 2>&1`
- JAVA_VERSION_OUTPUT=`echo $JAVA_VERSION_OUTPUT | sed 's/openjdk version/java version/'`
- check_java_version && {
- export JRE_PATH
- exec $JRE_PATH/bin/java "${args[@]}"
- }
- fi
-done
-
-# Failed
-if [ -x "`which xmessage`" ]; then
- xmessage -nearmouse -file - < /dev/null && pwd )
+exec $SCRIPT_DIR/ffdec.sh translator
diff --git a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
index 3d4fce0f0..18740bed1 100644
--- a/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
+++ b/src/com/jpexs/decompiler/flash/console/CommandLineArgumentParser.java
@@ -335,7 +335,14 @@ public class CommandLineArgumentParser {
public static void printCmdLineUsage(PrintStream out, boolean webHelp, String filter) {
int cnt = 1;
- out.println("@|underline,bold Usage|@: @|bold ffdec-cli|@ [PRE-OPTIONS] [COMMAND]");
+ out.println("@|underline,bold Usage|@: @|bold |@ [PRE-OPTIONS] [COMMAND]");
+ out.println();
+ out.println("@|underline,bold Executable|@:");
+ out.println(" Linux: ffdec or ffdec.sh");
+ out.println(" Mac OS: ffdec.sh");
+ out.println(" Windows: ffdec-cli.exe or ffdec.bat");
+ out.println(" Java: java -jar ffdec.jar");
+ out.println();
out.println("@|underline,bold Commands|@:");
if (filter == null) {
out.println("@|bold -help|@ | @|bold --help|@ | @|bold /?|@");
@@ -347,13 +354,13 @@ public class CommandLineArgumentParser {
}
if (filter == null || filter.equals("proxy")) {
- out.println("@|bold proxy|@ [-P]");
+ out.println("@|bold -proxy|@ [-P]");
out.println(" auto start proxy in the tray. Optional parameter -P specifies port for proxy. Defaults to 55555. ");
out.println();
}
if (filter == null || filter.equals("export")) {
- out.println("@|bold export|@ ");
+ out.println("@|bold -export|@ ");
out.println(" export sources to .");
out.println(" Exports all files from when it is a folder.");
out.println(" Values for parameter:");
@@ -380,61 +387,61 @@ public class CommandLineArgumentParser {
}
if (filter == null || filter.equals("dumpswf")) {
- out.println("@|bold dumpSWF|@ ");
+ out.println("@|bold -dumpSWF|@ ");
out.println(" dumps list of SWF tags to console");
out.println();
}
if (filter == null || filter.equals("dumpas2")) {
- out.println("@|bold dumpAS2|@ ");
+ out.println("@|bold -dumpAS2|@ ");
out.println(" dumps list of AS1/2 scripts to console");
out.println();
}
if (filter == null || filter.equals("dumpas3")) {
- out.println("@|bold dumpAS3|@ ");
+ out.println("@|bold -dumpAS3|@ ");
out.println(" dumps list of AS3 scripts to console");
out.println();
}
if (filter == null || filter.equals("compress")) {
- out.println("@|bold compress|@ [(zlib|lzma)]");
+ out.println("@|bold -compress|@ [(zlib|lzma)]");
out.println(" Compress SWF and save it to . If is already compressed, it will be re-compressed. Default compression method is ZLIB");
out.println();
}
if (filter == null || filter.equals("decompress")) {
- out.println("@|bold decompress|@ ");
+ out.println("@|bold -decompress|@ ");
out.println(" Decompress and save it to ");
out.println();
}
if (filter == null || filter.equals("encrypt")) {
- out.println("@|bold encrypt|@ ");
+ out.println("@|bold -encrypt|@ ");
out.println(" Encrypts file with HARMAN Air encryption and saves it to ");
out.println();
}
if (filter == null || filter.equals("decrypt")) {
- out.println("@|bold decrypt|@ ");
+ out.println("@|bold -decrypt|@ ");
out.println(" Decrypts HARMAN Air encrypted file and saves it to ");
out.println();
}
if (filter == null || filter.equals("swf2xml")) {
- out.println("@|bold swf2xml|@ ");
+ out.println("@|bold -swf2xml|@ ");
out.println(" Converts the SWF to XML file");
out.println();
}
if (filter == null || filter.equals("xml2swf")) {
- out.println("@|bold xml2swf|@ ");
+ out.println("@|bold -xml2swf|@ ");
out.println(" Converts the XML to SWF file");
out.println();
}
if (filter == null || filter.equals("extract")) {
- out.println("@|bold extract|@ [-o |] [nocheck] [(all|biggest|smallest|first|last)]");
+ out.println("@|bold -extract|@ [-o |] [nocheck] [(all|biggest|smallest|first|last)]");
out.println(" Extracts SWF files from ZIP or other binary files");
out.println(" -o parameter should contain a file path when \"biggest\" or \"first\" parameter is specified");
out.println(" -o parameter should contain a folder path when no extaction mode or \"all\" parameter is specified");
@@ -442,25 +449,25 @@ public class CommandLineArgumentParser {
}
if (filter == null || filter.equals("memorysearch")) {
- out.println("@|bold memorySearch|@ (|) (|)...");
+ out.println("@|bold -memorySearch|@ (|) (|)...");
out.println(" Search SWF files in the memory");
out.println();
}
if (filter == null || filter.equals("renameinvalididentifiers")) {
- out.println("@|bold renameInvalidIdentifiers|@ (typeNumber|randomWord) ");
+ out.println("@|bold -renameInvalidIdentifiers|@ (typeNumber|randomWord) ");
out.println(" Renames the invalid identifiers in and save it to ");
out.println();
}
if (filter == null || filter.equals("flashpaper2pdf")) {
- out.println("@|bold flashpaper2pdf|@ ");
+ out.println("@|bold -flashpaper2pdf|@ ");
out.println(" converts FlashPaper SWF file to PDF . Use -zoom parameter to specify image quality.");
out.println();
}
if (filter == null || filter.equals("replace")) {
- out.println("@|bold replace|@ (|) [nofill] ([][]) [(|) [nofill] ([][])]...");
+ out.println("@|bold -replace|@ (|) [nofill] ([][]) [(|) [nofill] ([][])]...");
out.println(" replaces the data of the specified BinaryData, Image, Shape, Text, Sound tag or Script");
out.println(" nofill parameter can be specified only for shape replace");
out.println(" parameter can be specified for Image and Shape tags");
@@ -468,26 +475,26 @@ public class CommandLineArgumentParser {
out.println(" parameter should be specified if and only if the imported entity is an AS3 P-Code");
out.println(" use -1 as characterId to replace main timeline SoundStreamHead");
- out.println("@|bold replace|@ ");
+ out.println("@|bold -replace|@ ");
out.println(" same as -replace command, but the rest of arguments is read as lines from a text file ");
out.println();
}
if (filter == null || filter.equals("replacealpha")) {
- out.println("@|bold replaceAlpha|@ [ ]...");
+ out.println("@|bold -replaceAlpha|@ [ ]...");
out.println(" replaces the alpha channel of the specified JPEG3 or JPEG4 tag");
out.println();
}
if (filter == null || filter.equals("replacecharacter")) {
- out.println("@|bold replaceCharacter|@ [ ]...");
+ out.println("@|bold -replaceCharacter|@ [ ]...");
out.println(" replaces a character tag with another character tag from the same SWF");
out.println();
}
if (filter == null || filter.equals("replacecharacterid")) {
- out.println("@|bold replaceCharacterId|@ ,,,... or");
- out.println("@|bold replaceCharacterId|@ (pack|sort)");
+ out.println("@|bold -replaceCharacterId|@ ,,,... or");
+ out.println("@|bold -replaceCharacterId|@ (pack|sort)");
out.println(" replaces the character id with ");
out.println(" pack: removes the spaces between the character ids (1,4,3 => 1,3,2)");
out.println(" sort: assigns increasing IDs to the character tags + pack (1,4,3 => 1,2,3)");
@@ -496,74 +503,74 @@ public class CommandLineArgumentParser {
}
if (filter == null || filter.equals("remove")) {
- out.println("@|bold remove|@ []...");
+ out.println("@|bold -remove|@ []...");
out.println(" removes a tag from the SWF");
out.println();
}
if (filter == null || filter.equals("removecharacter")) {
- out.println("@|bold removeCharacter[WithDependencies]|@ []...");
+ out.println("@|bold -removeCharacter[WithDependencies]|@ []...");
out.println(" removes a character tag from the SWF");
out.println();
}
if (filter == null || filter.equals("importsymbolclass")) {
- out.println("@|bold importSymbolClass|@ ");
+ out.println("@|bold -importSymbolClass|@ ");
out.println(" imports Symbol-Class mapping to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importmovies")) {
- out.println("@|bold importMovies|@ ");
+ out.println("@|bold -importMovies|@ ");
out.println(" imports movies to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importsounds")) {
- out.println("@|bold importSounds|@ ");
+ out.println("@|bold -importSounds|@ ");
out.println(" imports sounds to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importshapes")) {
- out.println("@|bold importShapes|@ [nofill] ");
+ out.println("@|bold -importShapes|@ [nofill] ");
out.println(" imports shapes to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importimages")) {
- out.println("@|bold importImages|@ ");
+ out.println("@|bold -importImages|@ ");
out.println(" imports images to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importsprites")) {
- out.println("@|bold importSprites|@ ");
+ out.println("@|bold -importSprites|@ ");
out.println(" imports sprites to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importtext")) {
- out.println("@|bold importText|@ ");
+ out.println("@|bold -importText|@ ");
out.println(" imports texts to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("importscript")) {
- out.println("@|bold importScript|@ ");
+ out.println("@|bold -importScript|@ ");
out.println(" imports scripts to and saves the result to ");
out.println();
}
if (filter == null || filter.equals("deobfuscate")) {
- out.println("@|bold deobfuscate|@ ");
+ out.println("@|bold -deobfuscate|@ ");
out.println(" Deobfuscates AS3 P-code in and saves result to ");
out.println(" can be one of: traps/2/max, deadcode/1");
out.println();
}
if (filter == null || filter.equals("enabledebugging")) {
- out.println("@|bold enabledebugging|@ [-injectas3|-generateswd] [-pcode] ");
+ out.println("@|bold -enabledebugging|@ [-injectas3|-generateswd] [-pcode] ");
out.println(" Enables debugging for and saves result to