Search code examples
javajarweka

Jar execution command error from first line


From this repository

I try to execute the command.

./PersonalityRecognizer -i ../output_dir -d -t 2 -a ../mairesse_Apache.arff

However I receive this error.

C:/weka/weka-3-4/weka.jar: line 1: $'PK\003\004': command not found
C:/weka/weka-3-4/weka.jar: line 2: syntax error near unexpected token `('
C:/weka/weka-3-4/weka.jar: line 2: `▒=1 META-INF/▒=1META-INF/MANIFEST.MF▒M▒▒LK-.▒K-*▒▒ϳR0▒3▒▒M▒▒▒u▒I,.▒R(O▒N▒K/▒▒s▒t▒▒▒/N-▒r.JM,IM▒u▒▒Rp▒+▒1▒3▒▒P▒׀NMPK'
./PersonalityRecognizer: line 15: : command not found

I have download weka jar file and give the path in the following file as requested by the instructions:

#! /bin/bash -

# ENVIRONMENT VARIABLES

JDK_PATH=../../apps/jdk1.5.0_05
WEKA=../../apps/weka-3-4/weka.jar

# ----------------------------------

COMMONS_CLI=./lib/commons-cli-1.0.jar
MRC=./lib/jmrc.jar

LIBS=.:$WEKA:$COMMONS_CLI:$MRC:bin/

$JDK_PATH/bin/java -Xmx512m -classpath $LIBS recognizer.PersonalityRecognizer $*

Solution

  • As jhenrique said, if you use windows you have to edit the PersonalityRecognizer.bat (you seem to have edited the bash script but ran on windows).

    Then you have to make sure the directory structure looks like this:

      \ Personality-Recognition-in-SD-master (this is the cloned repo's root)
        +---apps
        +---Classification
        +---data
        +---mrc
        +---output_dir
        \---PersonalityRecognizer (this contains the PersonalityRecognizer.bat and bash scripts, note the subdirectory)
    

    You also have to make sure you edit the PersonalityRecognizer.properties in PersonalityRecognizer subdir, to include your application path. If you use windows you have to use double / for path separator:

    ##################################################
    # Configuration File of the Personality Recognizer
    ##################################################
    
    # All variables should be modified according to your
    # directory structure
    
    # Warning: for Windows paths, backslashes need to be
    # doubled, e.g. c:\\Program Files\\Recognizer
    
    # Root directory of the application
    appDir = F:\\Personality-Recognition-in-SD-master\\PersonalityRecognizer
    
    # Path to the LIWC dictionary file (LIWC.CAT)
    liwcCatFile = lib/LIWC.CAT
    
    # Path to the MRC Psycholinguistic Database file (mrc2.dct)
    mrcPath = ../mrc/mrc2.dct
    

    Update: Also make sure, that the JDK_PATH and WEKA variables in the PersonalityRecognizer.bat point to a valid JDK path and WEKA path (weka.jar is contained in the repo you cloned):

    @echo off
    rem WINDOWS LAUNCH SCRIPT
    
    rem ENVIRONMENT VARIABLES TO MODIFY
    
    set JDK_PATH="C:\Program Files\Java\jdk1.6.0_01"
    set WEKA="F:\Personality-Recognition-in-SD-master\apps\weka-3-4\weka.jar"
    
    rem ----------------------------------
    
    set COMMONS_CLI="lib\commons-cli-1.0.jar"
    set JMRC="lib\jmrc.jar"
    
    set LIBS=%WEKA%;%COMMONS_CLI%;%JMRC%;%CD%;bin\
    
    %JDK_PATH%\bin\java -Xmx512m -classpath %LIBS% recognizer.PersonalityRecognizer %1 %2 %3 %4 %5 %6 %7 %8 %9