I've been trying to make opencv for linux, I used the cmake parameters:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_OPENCL=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_SHARED_LIBS=OFF -D JAVA_INCLUDE_PATH=$JAVA_HOME/include -D JAVA_AWT_LIBRARY=$JAVA_HOME/jre/lib/amd64/libawt.so -D JAVA_JVM_LIBRARY=$JAVA_HOME/jre/lib/arm/server/libjvm.so -D CMAKE_INSTALL_PREFIX=/usr/local
and it generated the files fine.
It was then into around the 81% when it was trting to generate the opencv-jar it opped up with
/home/pi/Desktop/opencv-3.1.0/modules/java/generator/src/cpp/common.h:8:17 fatal error jni.h No such file or directory
So I'm not sure what to be doing now with it. openjdk is installed properly too
Edit: I tried using the -I flag, by doing the command
make -I/usr/lib/jvm/java-8-openjdk-armhf/includes
to no avail
the -I flag on make(1) command only affects the files included in the makefile by the .include directive, not the directories searched for by the compiler. For that purpose, just pass the -I flag to each compilation. One way to do this is
$ make CFLAGS="-I/usr/lib/jvm/java-8-openjdk-armhf/includes"
you can also pass the CFLAGS from the environment, as in
$ export CFLAGS=\""-I/usr/lib/..."\" # escaped double quotes make them to be included in the string.
$ make
Please check: https://stackoverflow.com/a/67154438/1290868
FindJNI
find_package(JNI)
if (JNI_FOUND)
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
endif()
Related
I'm following a guide that only includes compilation instructions on windows. How would one run this build.bat file on Linux?
The batch file looks like this:
#echo off
#echo Compiling...
javac -classpath ..\..\lib\OneWireAPI.jar;%classpath% -d . .\src\*.java
And when I run the javac command on Linux, it fails:
javac -classpath ../../lib/OneWireAPI.jar;%classpath% -d . ./src/ReadTemp.java
The output is:
javac: no source files
What is the correct way to do this?
On Linux, you have to use : (colon) in place of ; (semicolon) as the path separator in Java options.
Also, if you have a classpath variable, in most common Linux shells it is referenced by $classpath rather than by %classpath%
javac -classpath ../../lib/OneWireAPI.jar:$classpath -d . ./src/ReadTemp.java
You have two items that did not get translated correctly from Windows CMD to Unix:
Path separator ; should be :.
Environment variables should be changed from %classpath% to $CLASSPATH format. Note that pretty much everything is case-sensitive in Linux, including environment variable names, and the Java path is traditionally all-caps.
Try
javac -classpath ../../lib/OneWireAPI.jar:$CLASSPATH -d . ./src/ReadTemp.java
I left an open issue for here
I´m trying to create a custom codegen, I managed to make it work by putting the files inside of the codegen project but I want it to work like this: https://github.com/swagger-api/swagger-codegen#making-your-own-codegen-modules
I haven't modified the autogenerated project at all but I keep getting:
Error: Could not find or load main class io.swagger.codegen.SwaggerCodegen
This is the command line:
java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation
I got the jar from here https://mvnrepository.com/artifact/io.swagger/swagger-codegen-project/2.1.6
This is what I'm doing:
Run java -jar swagger-codegen-cli-2.1.6.jar meta \ -o output/myLibrary -n myClientCodegen -p com.my.company.codegen to create costume codegen
Run mvn package in output/myLibrary
Run java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation in the folder that contains both swagger-codege-cli-2.1.6.jar and the output folder
It does find the class if I remove the first part, but doesn´t find the new language:
java -cp swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation
I have looked at the answers for "Error: Could not find or load main class" problems but haven't manage to fix it.
Here is a link to the jar
For Windows, change the colon (:) to a semicolon (;) - between the jars in the class path. So instead of
java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation
It should be
java -cp output/myLibrary/target/myCustomCodegen-swagger-codegen-1.0.0.jar;swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation
Multiple class paths need to be separated by a semicolon. http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
The problem is that you don't specify that correct path of swagger-codegen-2.1.6.jar in your call. Thats why it can't find the main-class.
If you are inside the root project swagger-codegen you should specify it like this: modules/swagger-codegen-cli/target/swagger-codegen-cli.jar
~$ cd ~/git/swagger-codegen # go into your root project
~/git/swagger-codegen$ # ... do the steps you described
~/git/swagger-codegen$ java -cp \
output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
io.swagger.codegen.SwaggerCodegen \
generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json \
-l com.my.company.codegen.Mycustomcodegengenerator \
-o outputlocation
Or as a one-liner:
~/git/swagger-codegen$ java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen generate -i https://watson-api-explorer.mybluemix.net/listings/conversation-v1-experimental.json -l com.my.company.codegen.Mycustomcodegengenerator -o outputlocation
Update 1
I'm pretty sure when you construct the classpath with -cp you have a mistake with the swagger-codegen-cli-2.1.6.jar. Please test the following.
Copy both (myClientCodegen-swagger-codegen-1.0.0.jar and swagger-codegen-cli-2.1.6.jar) jars into the same folder. Then go into this folder and try the following:
javap -cp myCustomCodegen-swagger-codegen-1.0.0.jar:swagger-codegen-cli-2.1.6.jar io.swagger.codegen.SwaggerCodegen
javap checks whether the main class io.swagger.codegen.SwaggerCodegen is available. On my machine it prints this:
Compiled from "SwaggerCodegen.java"
public class io.swagger.codegen.SwaggerCodegen {
public io.swagger.codegen.SwaggerCodegen();
public static void main(java.lang.String[]);
}
I had this similar problem when running as Spring Boot app in Eclipse 4.19 in macOS 10.14:
"Error: Could not find or load main class
io.swagger.Swagger2SpringBoot"
…even as I was staring at this very class containing the main method. My solution was issuing a "maven update project". This, like in other situations with odd Java symptoms, fixed the issue.
I need to store locally emails downloaded via POP3 and so I'm tring to use JavaMail Mbox Store, which is part of the JavaMail source code but not compiled.
https://java.net/projects/javamail/pages/MboxStore
I've followed the instructions at the end of this page, but with no luck. Here comes what the instructions says:
export MACH=`uname -p`
export JAVA_HOME=/usr/java
cd mbox
mvn
cd native
mvn
I've changed the JAVA_HOME variable according to my environment. I get no error until the last command. The docs says that by default these are the options used by maven:
mvn -Dcompiler.name=c89 \
-Dcompiler.start.options='-Xa -xO2 -v -D_REENTRANT -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/solaris' \
-Dlinker.name=c89 \
-Dlinker.start.options='-G' \
-Dlinker.end.options='-L${env.JAVA_HOME}/jre/lib/${env.MACH} -lmail -ljava -lc'
I've changed the compiler name to gcc and removed some options unrecognized by gcc (-Xa and -x02). Unfortunately, it complains about a missing maillock.h.
Do you know where I can find a complete list of dependencies? Am I doing something wrong with options? I've tried to look for any pre-compiled version, but I had no luck.
I'm trying to compile on Slackware 14.1.
On Ubuntu/Debian/Mint you need the liblockfile-dev package.
To build on Debian Whezzy I had to manually set the archecture and then add the -shared option to stop the undefined reference to main (asumming the linux equivalent to -G in Solaris). Also add the additional library path for linjvm which is under the server directory
export MACH=amd64
mvn -Dcompiler.name=c89 \
-Dcompiler.start.options='-v -D_REENTRANT -I${env.JAVA_HOME}/include -I${env.JAVA_HOME}/include/linux' \
-Dlinker.name=c89 \
-Dlinker.start.options='-shared' \
-Dlinker.end.options='-L${env.JAVA_HOME}/jre/lib/${env.MACH} -L${env.JAVA_HOME}/jre/lib/${env.MACH}/server -llockfile -ljava -jverify -ljvm -lc'
I am using sejda-console.bat and I am running into difficulties with parameters when there is a space involved.
I am trying to use the simplesplit feature and I am calling the console as follows:
call sejda-console.bat simplesplit -f %1 -o %~dp1 -s all
If the path to my file is:
Z:\Test\test.pdf
The script works perfectly. However if the path to my file is:
Z:\Test Folder\test.pdf
It fails with the following error:
call sejda-console.bat simplesplit -f "Z:\Test Folder\test.pdf" -o Z:\Test Folder\ -s all
18:16:29.746 Configuring Sejda 1.0.0.M2
18:16:29.777 Loading Sejda configuration form default sejda.xml
18:16:30.027 Starting execution with arguments: 'simplesplit -f Z:\Test Folder\test.pdf -o Z:\Test Folder\ -s all'
18:16:30.027 Java version: '1.7.0_25'
18:16:30.199 Option only takes one value: --output -o value : output directory (required)
I wonder is there anyone who is familiar with the sejda-console or just passing parameters with spaces that could point me in the right direction. I have searched widely and tried all possible combinations of parameters etc.
Thanks
I think you should use quotes for the -o option as well:
call sejda-console.bat simplesplit -f "Z:\Test Folder\test.pdf" -o "Z:\Test Folder\" -s all
I'd suggest to convert the long directory path names to short path names
For example: use C:\TESTFO~1\ as opposed to C:\test folder with spaces
This seems to solve the issue,
Below a working example calling the sejda-console from an AutoIt script
#include <Constants.au3>
Local $iPID, $sOutput = ""
$sFilePath = "C:\test folder with spaces\"
$sFileShort= FileGetShortName($sFilePath)
$iPID = Run(#ComSpec & " /C """ & #ScriptDir & "\sejda-console-2.10.4\bin\sejda-console.bat"" merge -l " & $sFileShort & "files.csv -o " & $sFileShort & "output.pdf --overwrite", "", #SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($iPID)
$sOutput = StdoutRead($iPID)
ConsoleWrite($sOutput)
sejdaspacesautoit
Having just hit and solved this exact problem, this is a sample of what I am passing to sedja.
simplesplit -j overwrite -s all -f "C:/Users/user/Desktop/PDF_splitting/pages.pdf" -o "C:/Users/user/Desktop/PDF_splitting/spaced path/" -p [BASENAME]_[CURRENTPAGE]
So, even though my system is Windows 10 I can use forward slash "/" as a path separator. Wrap the whole path in double quotes and it works.
I think the reason a 'normal' path string doesn't work is that the backslash "\" is an escape character in Java.
I am trying to call a java program in php to use it with web interface.
Java program is dependent on an external lib: commons-cli-1.2.jar
So basically I need to export it before calling the java program; but if I export it first as:
shell_exec('export CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar');
then call the java program as:
shell_exec('java ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o');
I think it creates different shells for each call; then the export does not have any effect on java program. Or am I wrong?
Otherwise, it should output a file in the server. But simply it does not. So, what is wrong? Any idea?
edit: However can it be because some parameters such as para_i stands for an input file name, so that i have to specify full path for that? Because I just assume if the input file is in the same working directory, there won't be any problem, will it?
edit-2: it outputs properly when i use command line;)
you're right, each shell_exec creates a separate shell.
env CLASSPATH=whatever java -switches
I would use
shell_exec('java -cp $CLASSPATH:/home/yourname/dir/lib/commons-cli-1.2.jar ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
and (this is important) replace the tilde(~) with the actual path to your directory (/home/yourname say). The ~ is expanded by the shell and is dependent on which shell you''re using.
Try Creating a simple shell script with the commands that you want to execute. You may pass arguments to a shell script so that is not a problem either.
for example
echo "Running Script..."
java -cp $CLASSPATH:~/lib/commons-cli-1.2.jar ComputePagerank -i $1 -d $2 -e $3 -o $4 > message
etc.
Then try calling it from the command line first with some parameters. Did it output? Then try calling it from the php script. Did it output? If it did not then you may need to check permissions. I had a simiolar experience some time ago with a Java program that simply did not have permission to write a file.
You should be able to call it like this.
shell_exec('java -cp $CLASSPATH:~/lib/commons-cli-1.2.jar ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
Another option is to issue the 2 commands seperately, but to the same shell, like this:
shell_exec('export CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar; java ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
edit:
some shells don't let you call export while you're setting up the variable. so this may be safer than the second option above:
shell_exec('CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar; export CLASSPATH; java ComputePagerank -i $para_i -d $para_d -e $para_e -o $para_o > message');
another edit:
If none of the above work then you're going to have to do some more trouble shooting. Does your java program work from the command prompt?
java -cp $CLASSPATH:/home/user/lib/commons-cli-1.2.jar ComputePagerank -i param1 -d param2 -e param3 -o param4 > message