Generating Java header file error - java

Sorry for asking but I am having trouble generating a Java header file from my code - in command prompt I typed:
javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main
From what I've read that should have worked but I get this error:
Error: Could not find class file for 'jnidemojava.Main'.
Before you say I forgot to clean and build to compile it I did, but I still have this error if you need more info just ask .
Update: Problem was solved

It seems your command is right. In which platform you run your command? Be cautious to the file separator, it's \ in Windows and / in *NIX.
So in Windows you should
javah -o JNIDemoJava.h -classpath JNIDemoJava\build\classes jnidemojava.Main
In *NIX, you should
javah -o JNIDemoJava.h -classpath JNIDemoJava/build/classes jnidemojava.Main

Related

javac: invalid flag: activation-1.1.jar

I'm using Tomcat7 , jdk 1.7.0_55 & eclipse, when I trying to compile the entire project(Java Code) using COMMAND PROMPT, its showing Error Like
javac: invalid flag: D:\COMPILE\lib\activation-1.1.jar.
The given below steps are followed to compile the code.
Step.1: dir *.java /s /b > FilesList.txt
Step.2: javac #FilesList.txt -d compiledCode -cp D:\COMPILE\lib\*.jar
After run the Step.2 command its showing Error.so I removed the error jar file from my lib folder & run the command but its showing same error with another jar.
Note: I Already have ANT build.xml but I want to compile the project through COMMAND PROMPT.
The lib*.jar gets expanded by the command shell. You need to avoid that by using quotes.
***** -cp "D:\COMPILE\lib\*" *****
The argument to -cp is a single path list (like $PATH, not multiple arguments with one path each). Multiple files can be separated by : (or ; on Windows)

Ubuntu: javac package gnu.io does not exist

I am running on Ubuntu 12.04. I am trying to communicate my Arduino with Java.
I have a source file SerialTest.java in directory /home/me/Desktop/folder
Inside the directory contains both RXTXcomm.jar, librxtxSerial.so, and my source code file.
I tried these methods to compile the SerialTest.java:
$ javac SerialTest.java
and I get the following errors:
SerialTest.java:4: error: package gnu.io does not exist
$ javac -verbose -classpath .:RTXXcomm.jar SerialTest.java
And I got the same error
SerialTest.java:4: error: package gnu.io does not exist
What I have referred to: javac -classpath not doing the trick
May I know what I am doing wrong? I am new to this. Thank you.
Your classpath option is wrong. It should be:
-classpath .:RTXXcomm.jar
Note the colon (:). The semicolon (;) is used as a command separator by the shell.
What happens currently is that this command is executed:
javac -verbose -classpath .
Hence the first error: "no source files". And then this command is passed:
RTXXcomm.jar SerialTest.java
Hence the second error: "RXTXcomm.jar: command not found."

javac: invalid flag: .getting error when compiling a java servlet

i run command
javac -classpath /home/coolhunk/JBoss/jboss-6.0.0.Final/common/lib/jboss-servlet-api_3.0_spec.jar -d helloapp.war/WEB-INF/classes -sourcepath src/com/manning/jbia/intro/*
for generating java class files.but i am getting error
javac: invalid flag: src/com/manning/jbia/intro/HelloWorldServlet.java~
Usage: javac <options> <source files>
use -help for a list of possible options
can anyone please point out what is the mistake in this command ??
Try these commands using tomcat, place your servlet source in src folder and run these,
C:\Documents and Settings\ssit>cd C:\src
C:\src>javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 6.0\
lib\servlet-api.jar" MyServlet.java
you can get the class file for the servlet. After getting the class file make the war file.
javac -classpath /home/coolhunk/JBoss/jboss-6.0.0.Final/common/lib/jboss-servlet-api_3.0_spec.jar -d helloapp.war/WEB-INF/classes -sourcepath src/com/manning/jbia/intro/*
The problem is the last item. The wildcard causes it to be expanded into everything in the directory, which causes everything after the first expansion to be treated as a source file name. The expansions also appear to include src/com/manning/jbia/intro/HelloWorldServlet.java~, which the compiler doesn't want to know about.
Try this:
javac -classpath /home/coolhunk/JBoss/jboss-6.0.0.Final/common/lib/jboss-servlet-api_3.0_spec.jar -d helloapp.war/WEB-INF/classes -sourcepath src src/com/manning/jbia/intro/*.java

-I flag JAVA command # .bat CMAKE

I have to extract and generate some .h files from a jar and idl file.
Need to use a .bat from external developers:
#echo off
java -jar C:\WorkspaceSwim\trunk\iB\build\BlueGen\target\bluegen.jar -o C:\WorkspaceSwim\trunk\Example\Distribution\build\GeneratedDDSFiles C:\WorkspaceSwim\trunk\Example\Distribution\Flight.idl
set NDDSHOME=C:\WorkspaceSwim\trunk\iB\build\ToolBox\NDDS
set RPCDDSHOME=C:\WorkspaceSwim\trunk\iB\build\ToolBox\RPCDDS
setlocal
set dir=%~dp0
set args=%1
:getarg
shift
if "%~1"=="" goto continue
set args=%args% %1
goto getarg
:continue
set JREHOME=%JAVA_HOME%
"%JREHOME%\bin\java" -DPATH="%PATH%" -DNDDSHOME="%NDDSHOME%" -DRPCDDSHOME="%RPCDDSHOME%" -Djava.ext.dirs="%RPCDDSHOME%\classes\" com.eprosima.rpcdds.idl.RPCDDSGEN %args% "-I%RPCDDSHOME% /idl"
I think there are some fail on the script , but i can't see it. Maybe a problem with quotes? i tryied this 3 posibilities :
"%JREHOME%\bin\java" -DPATH="%PATH%" -DNDDSHOME="%NDDSHOME%" -DRPCDDSHOME="%RPCDDSHOME%" -Djava.ext.dirs="%RPCDDSHOME%\classes\" com.eprosima.rpcdds.idl.RPCDDSGEN %args% "-I%RPCDDSHOME%\idl"
Error: principal class \idl doesn't found or load
"%JREHOME%\bin\java" -DPATH="%PATH%" -DNDDSHOME="%NDDSHOME%" -DRPCDDSHOME="%RPCDDSHOME%" -Djava.ext.dirs="%RPCDDSHOME%\classes" com.eprosima.rpcdds.idl.RPCDDSGEN %args% "-I%RPCDDSHOME%\idl"
Error: principal class com.eprosima.rpcdds.idl.RPCDDSGEN doesn't found or load
"%JREHOME%\bin\java" -DPATH="%PATH%" -DNDDSHOME="%NDDSHOME%" -DRPCDDSHOME="%RPCDDSHOME%" -Djava.ext.dirs="%RPCDDSHOME%\classes\ com.eprosima.rpcdds.idl.RPCDDSGEN %args%" -I "%RPCDDSHOME%\idl"
Unrecognized option: -I
Error: Could not create the Java Virtual Machine.
Previusly i use this .cmake to generate the code that will run this .bat
add_custom_command(
OUTPUT ${DDSGeneratedFiles}
COMMAND java -jar ${iB_BlueGen} -o ${GeneratedDDSDirName} ${LocatedFile}
COMMAND "set NDDSHOME=${iMASBlue_NDDS_DIR} &" "set RPCDDSHOME=${iB_RPCDDS_DIR} &" ${RPCDDSGenerator} -replace -d ${GeneratedDDSDirName} -I${CMAKE_CURRENT_SOURCE_DIR} ${LocatedFile}
DEPENDS ${IncludeDependencies}
MAIN_DEPENDENCY ${LocatedFile}
COMMENT "Calling RPCDDS Generator '${RPCDDSGenerator}' on '${IdlFile}'"
)
Thnx for your answers.
To debug batch files, change line
#echo off
in your batch file to
#echo on
and run again

Java compiler linux

I was on windows and my compiler code was
#echo off
"C:\Program Files\Java\jdk1.6.0_29\bin\javac.exe" -classpath deps/log4j-1.2.15.jar;deps/jython.jar;deps/xstream.jar;deps/mina.jar;deps/mysql.jar;deps/poi.jar;deps/slf4j.jar;deps/slf4j-nop.jar -d bin src\server\event\*.java src\server\model\items\*.java src\server\model\minigames\*.java src\server\model\npcs\*.java src\server\model\objects\*.java src\server\model\players\*.java src\server\model\players\skills\*.java src\server\model\players\packets\*.java src\server\model\shops\*.java src\server\net\*.java src\server\task\*.java src\server\util\*.java src\server\world\*.java src\server\util\log\*.java src\server\*.java src\server\world\map\*.java
pause
Now when I moved to linux, it doesn't work.
I've tried to change it to .sh file and edited like this
javac -classpath deps/log4j-1.2.15.jar:deps/jython.jar:deps/xstream.jar:deps/mina.jar:deps/mysql.jar:deps/poi.jar:deps/slf4j.jar:deps/slf4j-nop.jar -d bin src/server/event/*.java src/server/model/items/*.java src/server/model/minigames/*.java src/server/model/npcs/*.java src/server/model/objects/*.java src/server/model/players/*.java src/server/model/players/skills/*.java src/server/model/players/packets/*.java src/server/model/shops/*.java src/server/net/*.java src/server/task/*.java src/server/util/*.java src/server/world/*.java src/server/util/log/*.java src/server/*.java src/server/world/map/*.java
Basically I changed ; to :, \ to /
After running sh compile.sh in shell, I get error.
javac: invalid flag: src/server/world/map/*.java
Usage: javac <options> <source files>
use -help for a list of possible options
: not found 2: compile.sh:
Anyone know what I am doing wrong?
Doing a little research it seems this problem might be caused by incorrect line endings in your .sh file. Have you tried completely retyping it in vi, emacs, vim, or something like that?

Categories