Using CPD/PMD on the command line - ide

I'm using PMD currently as an external tool in conjunction with ace editor on an online java IDE i'm developing. However I can't get the CPD batch file to work, I've tried the command they provide on the website documentation as well as a few alternatives.
Could someone please give me the required command if i want to search for duplicate code?
here is my cpd directory and project source.
C:\Users\Neema\Desktop\pmd-bin-5.2.2\bin
C:\Users\Neema\workspace\Gillespie\src
I know this is simple, but if anyone could help it would bee GREATLY appreciated.
Thank you

You should be able to start cpd with this command line:
C:\Users\Neema\Desktop\pmd-bin-5.2.2\bin\cpd --minimum-tokens 100 --files C:\Users\Neema\workspace\Gillespie\src --language java
Note, that cpd is a command line tool - if you don't run it from a console (e.g. cmd), then you won't see the output. You can try to redirect stdout into a file via this command line:
C:\Users\Neema\Desktop\pmd-bin-5.2.2\bin\cpd --minimum-tokens 100 --files C:\Users\Neema\workspace\Gillespie\src --language java > C:\Users\Neema\workspace\Gillespie\src\cpd-results.txt
The CPD documentation unfortunately doesn't describe to use the simple cpd.bat file in the bin folder (like above)...

Related

How to run a karate script using power-shell command prompt

In power-shell window command prompt how to run a karate script. can you briefly explain the process on this.
Download the standalone JAR file: https://github.com/intuit/karate/tree/master/karate-netty#standalone-jar
Assuming you have the JAR and feature file in the same directory, you can trigger the script from the command prompt using the following command:
> karate.jar testscript.feature
Since you are new to stack overflow, please do read the following to best get help:
https://stackoverflow.com/help/how-to-ask
https://stackoverflow.com/help/someone-answers

Valgrind log both xml.log and text.log at the same time

I wanted to log both xml and text output results of valgrind memcheck.
I tried this command .
valgrind --tool=memcheck --xml=yes --log-file=TextLog.log --xml-file=XMLFile.log test
but only xml file was written.text file had no data..
No need of using tool option to set it to 'memcheck', since by default valgrind uses 'memcheck' as the tool. Just for your information.
Even there is no issue also, in using tool option.
Try using the below command, to get the logs in both XML file and log file.
valgrind --xml=yes --xml-file=XMLFile.log > Textlog.log 2>&1 test
Is this one you are expecting?
more information can be found in below link,
http://valgrind.org/docs/manual/manual-core.html#manual-core.basicopts

Run IntelliJ code formatter from the command line

I am trying to run IntelliJ code formatter from command line.
I know that inspections can be run from CLI, however, they didn't provide the same for the source formatting (lame!).
Now, I started with CE edition of IntelliJ. Source code is on github.
However, since the code base is not small, I am having problems encapsulating the formatter.
Is there anyone who can point me in right direction and showing which classes to start with?
You can run the formatter from the terminal now. Like the code inspection.
https://confluence.jetbrains.com/display/IDEADEV/Command-Line+Source+Code+Formatter
/bin/format.sh [-h] [-r|-R] [-s|-settings settingsPath] [-m|-mask masks] [path1 [path2]...]
On Windows it's /bin/format.bat
To do this in the new versions of Intellij
You need to make sure the command line launcher is installed via the Jetbrain Toolbox.
Toolbox App Announcement
And run the following command from your shell:
idea format -s /path/to/your/style.xml /path/to/your/folder
I would recommend that you set the shell script location to /usr/local/bin/

I am trying to open Jmeter by the batch file but it gives me a Windows error

Here is the related error its showing:
java.exe is not a recognized file as an internal or external command,
operable or external command
errorlevel=9009
i was getting the same error on WIndows 8.1(64 bit) and checked java path but it was ok
so i just run my jmeter.bat with Run as Administrator and it worked for me
Many operating systems have an environment variable such as PATH that contains a list of directories (or folders) to be searched when looking for a command to execute. Commands that can be found via the PATH are commonly called external commands. The program that reads the command line or the batch file and invoked the commands may have a number of built in commands, these are commonly called internal commands.
I suggest you examine the PATH (or equivalent) set when your java command executes from the command line and also when execution is attempted from the batch file. Compare the two and make sure the directory containing your java.exe is in the PATH.
Does not work with Java 9 beta:
Running:
C:\java -version
Gives:
java version "9-ea"
Just go into command line and run:
java -jar ApacheJMeter.jar
Set the correct Java Path (installed in your system) in Computer -> Advanced System settings -> Environment Variables -> Ok -> System Variables -> Path
I got the same issue and resolved by following the above steps.
I tried everything, this eventually worked.
Within System Variables:
PATH = "C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0_101\bin"
May help someone.
This error occurs due to the path has not been set properly.
Either you can set it in environmental varialables or right click jmeter .bat file,choose edit set the path their,for reference see the jmeter.apache.org user manuals.
For me, my Java path has a space in it and jmeter said it can't find Java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
.. I looked at the jmeter.sh script and saw it got the path from "Plugin-Ins" .. onward. I tried just commenting out the exit command after that check in the script .. and then I was able to run jmeter.
So apparently the validation logic has a bug, where the error message about can't find java is in fact not true (if Java is indeed set up correctly), so it can be ignored.
For windows 8.1 Users:
Error when trying to run jmeter.bat
Error message:
Not able to find Java executable or version. Please check your Java installation. errorlevel=2
Press any Key to continue
Resolution:
Right Click jmeter.bat and Run as Administrator.
This worked for me, hope this helps. Good luck
Set the correct JM_LAUNCH variable to java.exe
For Windows XP users set Java environment by following the steps here:
http://www.tutorialspoint.com/jmeter/jmeter_environment.htm
Note the path depends on your installed JDK.
And download the file from:
https://svn.apache.org/repos/asf/jmeter/trunk/bin/jmeter.bat
Then replace your jmeter.bat with the downloaded file.
If you have installed Java and still you get this error, please set the java_home path to below using typing below command in terminal:
export JAVA_HOME="/Library/InternetPlugIns/JavaAppletPlugin.plugin/Contents/Home"
Since I run many versions of Java.. I modified jmeter.bat.
rem JM_START - set this to "start" to launch JMeter in a separate window
rem this is used by the jmeterw.cmd script.
rem
rem =====================================================
setlocal
rem Minimal version to run JMeter
set MINIMAL_VERSION=1.8.0
set PATH=%PATH%;C:\Program Files (x86)\IBM\Java80\jre\bin <<< add This line to jmeter.bat
Copied the JAVA executable from Installed version of Java from C:\Program FilesJava\jdk1.8.0_191\bin and pasted in the folder where the jmeter bat resides and it worked for me.
Not exactly the same issue but somebody might find it helpful
Do not double click jmeter.bat but instead ApacheJMeter.jar in the same directory
For me jmeter.bat run but for a brief moment closing almost immediately and not prompting any error. Above workaround allowed me to start working
if JAVA -version shows as blank or empty in the command prompt (CMD) then you need to clear the all java paths in environment variable and again add JAVA_HOME=C:\Program Files\Java\jdk-11.0.15.1
path= C:\Program Files\Java\jdk-11.0.15.1\bin;
if you see C:\Program Files\Common Files\Oracle\Java\javapath; like this remove this
and try in new CMD prompt then Java -version will work.

How can I use Lucene in cmd

I am trying to use lucene on the Windows' command line as given in this link.
I have created the CLASSPATH variable for all four mentioned .jar files, but after that, when I run the command:
java org.apache.lucene.demo.IndexFiles -docs C:/lucene/src
it returns the following error:
could not find or load main class org.apache.lucene.demo.IndexFiles
I dont know what's wrong with it... Can anybody help me out?
I am a student and just a beginner.
Thanks
I ran into a similar issue, you need to include the CLASSPATHs in your command (if its not in environment vars). So it should be:
java -classpath C:\lucene\lucene-5.1.0\core\lucene-core-5.1.0.jar;C:\lucene\lucene-5.1.0\queryparser\lucene-queryparser-5.1.0.jar;C:\lucene\lucene-5.1.0\analysis\common\lucene-analyzers-common-5.1.0.jar;C:\lucene\lucene-5.1.0\demo\lucene-demo-5.1.0.jar org.apache.lucene.demo.IndexFiles -docs C:\lucene\lucene-5.1.0
And to search, you'd do:
java -classpath C:\lucene\lucene-5.1.0\core\lucene-core-5.1.0.jar;C:\lucene\lucene-5.1.0\queryparser\lucene-queryparser-5.1.0.jar;C:\lucene\lucene-5.1.0\analysis\common\lucene-analyzers-common-5.1.0.jar;C:\lucene\lucene-5.1.0\demo\lucene-demo-5.1.0.jar org.apache.lucene.demo.SearchFiles
It would be nice if Lucene would have a start scripts packaged to play araonud with ... I've created an indexfiles.cmd in my installation root directory with this content:
java -classpath core\lucene-core-7.4.0.jar;queryparser\lucene-queryparser-7.4.0.jar;analysis\common\lucene-analyzers-common-7.4.0.jar;demo\lucene-demo-7.4.0.jar org.apache.lucene.demo.IndexFiles %*
and another one called searchfiles.cmd:
java -classpath core\lucene-core-7.4.0.jar;queryparser\lucene-queryparser-7.4.0.jar;analysis\common\lucene-analyzers-common-7.4.0.jar;demo\lucene-demo-7.4.0.jar org.apache.lucene.demo.SearchFiles %*