ECLIPSE - Exception occurred executing command line - java

I have a MAC with java 7 and when I try to execute my code eclipse generates this error:
Exception occurred executing command line. Cannot run program "/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java" (in directory "/Users/mrcf/Documents/Università/EclipseWS/Clean"): error=2, No such file or directory
Can you help me?
Please, are two days that I try but without success.
Thanks.

Try changing Università to Universita in directory name

Related

A ClassNotFundExxseption error occurs when the registration and initialization command is executed

I have java project JavaProject4. In folder lib, I added file postgresql-42.2.2.jre7.jar (postgres driver). Next, I execute the following command:
Class.forName("org.postgresql.Driver").newInstance();
The command terminates with an error:
type: ClassNotFoundException detailMessage: "org.postgresql.Driver"
Question: how do I fix this error?
P.S. I'm a little versed in Java and the development environment of Netbeans.

Run Python script from java code

This is the first time I am trying python in java.
I am trying to execute python script from my code as follows.
Process process = Runtime.getRuntime().exec("python C:\\Users\\username\\Desktop\\demo\\filename.py");
But I am getting following exception
"Cannot run program "python": CreateProcess error=2, The system cannot find the file specified"
I have installed python.
I am not sure why the file is not found.
I tried to follow this link but it did not solve my issue.
Thanks in advance.
Edit 1
I tried the sample code given by "Viacheslav Vedenin", it worked when I executed my java(servlet) program. But when I ran the same function from JSP button click event, it did not work.
It gave me following error
java.io.IOException: Cannot run program "python": CreateProcess error=2, The system cannot find the file specified
Please help me to resolve this issue.
Try to use full path to python, for example
Process process = Runtime.getRuntime().exec("C:\\Python\\python.exe
C:\\Users\\username\\Desktop\\demo\\filename.py");

The system cannot find the file specified at java.lang.ProcessBuilder.start

I am a novice at programming. I have recently tried to download the source code of an open source software and setup the environment. However, I am seeing the following issue when I tried to run the build for the first time:
Execute failed: java.io.IOException: Cannot run program "unzip" (in directory "....\"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start
Any tips on how to resolve this issue?
From what I understand, it is unable to a file:
where exactly to look for ProcessBuilder.start
How do I modify it?
Try this:
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command("Write command here").start();
Edit: Command - string array which begin with fullpath to your programm. For example:
processBuilder.command("C:\\Program Files (x86)\\Microsoft Office\\Office15\\OUTLOOK.exe").start();

ProcessBuilder can't find perl

I'm trying to execute a perl script from java with the following code:
ProcessBuilder script =
new ProcessBuilder("/opt/alert-ssdb.pl");
Process tmp = script.start();
But when I execute it it returns
java.io.IOException: Cannot run program "/opt/alert-ssdb.pl": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:488)
at scripttest.main(scripttest.java:11)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:164)
at java.lang.ProcessImpl.start(ProcessImpl.java:81)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:470)
... 1 more
about the file
ls -l alert-ssdb.pl
-rwxr-xr-x. 1 root root alert-ssdb.pl
I tried running /usr/bin/perl/ with the script as an argument and it also failed with the same exception.
/bin/ls and other simple commands run without a problem though.
Also the first line of the script is #!/usr/bin/perl
and when run on command line it works
what am I missing?
//Update:
The big picture is that I'm trying to call the script via a storm bolt and it fails at that point.
I managed to make it work by defining a python script as a bolt
using
super(python,myscript.py)
(myscript imports the storm library) and from myscript I call the perl script.
I haven't tried yet but I suppose that If I modify the perl script to be a storm bolt it will run nicely.
Try changing
new ProcessBuilder("/opt/alert-ssdb.pl");
to:
new ProcessBuilder("/usr/bin/perl", "/opt/alert-ssdb.pl");
I've had past experiences where not all my environment variables from the shell exist when using ProcessBuilder.
Edited to reflect #dcsohl's comment.

Problem using JNI - Error when generating header file

I used the following guide to get started, http://cnd.netbeans.org/docs/jni/beginning-jni-win.html.
But when I try to generate the header file using the command below
JAVA_HOME\bin\javah.exe -o
HelloWorldNative.h -jni
-classpath PROJECTS_ROOT\HelloWorld\build\classes
helloworld.Main
I get the following error.
Error: Can't recover from an I/O
error with the following message:
HelloWorldNative.h (access denied)
Thanks in advance :)
Looks to me like you are standing in a directory where you are not granted write access when you run javah.
Edit: What if you specify a full path to somewhere you know you have write access?
I also got that problem and this is how I solved it:
After building your project,go to the directory where your .class files are.
e.g C:\Users\Development\Documents\NetBeansProjects\DLLDevelopment\build\classes
and run your command again.

Categories

Resources