Exception in compiling code with JavaCPP? - java

I am trying to run there own example of LegacyLibrary on http://code.google.com/p/javacpp/
when I try to compile code with following command mentioned at site only (basically compiling code with javacpp.jar) I am getting following exception
D:\Java Workspace\POC\JavaCPP\bin>java -jar javacpp.jar LegacyLibrary
Generating source file: D:\Java Workspace\POC\JavaCPP\bin\jniLegacyLibrary.cpp
Building library file: D:\Java Workspace\POC\JavaCPP\bin\windows-x86\jniLegacyLibrary.dll
cl "/IC:\Program Files (x86)\Java\jdk1.6.0_03\include" "/IC:\Program Files (x86)\Java\jdk1.6.0_03\include\win32" "D:\Java Workspace\POC\JavaCPP\bin\jniLegacyLibrary.cpp" /W3 /Oi
/O2 /EHsc /Gy /GL /MD /LD /link "/OUT:D:\Java Workspace\POC\JavaCPP\bin\windows-x86\jniLegacyLibrary.dll"
Exception in thread "main" java.io.IOException: Cannot run program "cl": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at com.googlecode.javacpp.Builder.build(Builder.java:189)
at com.googlecode.javacpp.Builder.generateAndBuild(Builder.java:234)
at com.googlecode.javacpp.Builder.main(Builder.java:479)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 3 more
what the remedy for this ?

The error message is pretty clear: it's not finding the cl executable, which is the name of the Visual Studio compiler.
You should run that command from a Visual Studio command prompt (there's an entry in the start menu for that, usually), to get the right environment variables loaded.

Related

"Failed to parse poms" Jenkins maven build

I am new to Jenkins and I am trying to integrate it with Cucumber and Maven ( so i can schedule automated scripts) but whenever I try to run my build I receive the following error:
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "/bin/java" (in directory "C:\Users\rharrigan\Documents\TestingScripts\tcwebsitelinks"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:245)
at hudson.Proc$LocalProc.<init>(Proc.java:214)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:846)
at hudson.Launcher$ProcStarter.start(Launcher.java:384)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:278)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:798)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1728)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 13 more
[CucumberReport] Preparing Cucumber Reports
[CucumberReport] Copied 0 json files from workspace "C:\Program Files (x86)\Jenkins\workspace\CucumberTest" to reports directory "C:\Program Files (x86)\Jenkins\jobs\CucumberTest\builds\9\cucumber-html-reports\.cache"
ERROR: Build step failed with exception
java.lang.IllegalStateException: basedir C:\Program Files (x86)\Jenkins\jobs\CucumberTest\builds\9\cucumber-html-reports\.cache does not exist.
at org.apache.tools.ant.DirectoryScanner.scan(DirectoryScanner.java:879)
at net.masterthought.jenkins.CucumberReportPublisher.findJsonFiles(CucumberReportPublisher.java:148)
at net.masterthought.jenkins.CucumberReportPublisher.generateReport(CucumberReportPublisher.java:101)
at net.masterthought.jenkins.CucumberReportPublisher.perform(CucumberReportPublisher.java:73)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1067)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
at hudson.model.Run.execute(Run.java:1753)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:544)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Build step 'Cucumber reports' marked build as failure
Finished: FAILURE
Any ideas or suggestions would be much appreciated.

Executing Windows shell commands using 'not-installed' Java

I can't install Java on the computer, I only have a 'Java folder' on my desktop. Because of that executing 'cmd.exe' commands with Java doesn't work. Is there any method of pointing to the 'cmd.exe' and telling java to run a command using it?
I mean somethind similar to what I do in my 'start.bat' file i use to run .jar's - start C:\Users\kamilkime\Desktop\JEclipse\Java\jdk1.7.0_75\bin\java -jar Calculator.jar
I tried using this two methods, both don't work and throw the same exception:
//Method 1
Runtime.getRuntime().exec("cls");
//Method 2
ProcessBuilder builder = new ProcessBuilder("cls");
builder.start();
//Exception stacktrace
java.io.IOException: Cannot run program "cls": CreateProcess error=2, Nie można odnaleźć określonego pl
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at java.lang.Runtime.exec(Runtime.java:617)
at java.lang.Runtime.exec(Runtime.java:450)
at java.lang.Runtime.exec(Runtime.java:347)
at com.gmail.kamilkime.Main.clearConsole(Main.java:82)
at com.gmail.kamilkime.Main.start(Main.java:61)
at com.gmail.kamilkime.Main.main(Main.java:36)
Caused by: java.io.IOException: CreateProcess error=2, Nie można odnaleźć określonego pl
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
at java.lang.ProcessImpl.start(ProcessImpl.java:136)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 6 more
//edit 08.10.2015
Ok, so thanks to #9dan I've managed to run a console window, but... Now I can't do anything with it - cannot println() a message, cannot get a user input. Is it posibble to do sth like that (printing/getting input)?
BTW, the thing I'm trying to do the whole time is finding a way to enable the console program by double-clicking the .jar file, not by using 'java' command in 'cmd.exe'.
Now, I'm using this code and I'm stuck - I don't know what to do: http://pastebin.com/VLkr1RFd

Error under the following program to write R Script separately

Calling R in java-Rcaller
After following above link I've created new "myScript.R" seperately.
Please tell me that it is showing "save workspace" for saving. I've saved it as file with .R extension. Please correct me if I'm wrong.
I'm recieving the following error on running this as same Java program (provided in above link) created in Netbeans IDE for connecting RCaller with Java:
run:
java.io.IOException: Cannot run program "Rscript": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at javaapplicationrcaller2.JavaApplicationRCaller2.<init>(JavaApplicationRCaller2.java:41)
at javaapplicationrcaller2.JavaApplicationRCaller2.main(JavaApplicationRCaller2.java:25)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:288)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
... 5 more
BUILD SUCCESSFUL (total time: 0 seconds)

How to run setup.exe file using java

I am developing an java application from which I have to run xyz_setup.exe installer. I tried the following code
String command = "C:\\xyz_setup.exe";
Runtime.getRuntime().exec(command);`
But it was throwing the following error
java.io.IOException: Cannot run program "C:\Users\NewtonApples\Downloads\idman614.exe": CreateProcess error=740, The requested operation requires elevation
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
at java.lang.Runtime.exec(Runtime.java:615)
at java.lang.Runtime.exec(Runtime.java:448)
at java.lang.Runtime.exec(Runtime.java:345)
at upendra.OpenExternalApplication.main(OpenExternalApplication.java:19)
Caused by: java.io.IOException: CreateProcess error=740, The requested operation requires elevation
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:189)
at java.lang.ProcessImpl.start(ProcessImpl.java:133)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
... 4 more
Can any one suggest me how to do this?
Java (or likely any other process which uses CreateProcess system call directly) is not good with executables requiring access elevation.
You can get around that by executing your program via shell:
String command = "C:\\setup.exe";
Runtime.getRuntime().exec("cmd /c "+command);

How to clear console in java (Using netbeans)

I am using jdj 1.7,netbeans 7 versions. I wrote a program that's working fine. Now i want to clear the console window after many outputs in the console. I tried the below line Runtime.getRuntime().exec("cls"); also tried with exec("clear"). But i am getting these errors:
Exception in thread "main" java.io.IOException: Cannot run program "cls": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at Periodical.main(Book.java:88)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
What's the problem here. How can i clear the console? Thank you
If you want to keep it portable you might want to use a library like jcurses. That will save you the trouble of having to detect what kind of console/terminal you are on and will give you a lot of other nice features like cursor and color control.

Categories