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?
Related
I was doing WordCount using Ubuntu Shell, when I was Compile the java code by using the following command as mentioned below
javac -classpath ${HADOOP_CLASSPATH} -d
‘/home/abdullah/Desktop/WordCountTutorial/tutorial_classes’
‘/home/abdullah/Desktop/WordCountTutorial/WordCount.java’
I got the error below
javac invalid flag:‘/home/abdullah/Desktop/WordCountTutorial/tutorial_classes’
‘/home/abdullah/Desktop/WordCountTutorial/WordCount.java’
Usage: javac <options> <source files>
use -help for a list of possible options
I can observe following issues:
Quotes: Don't give quotes. -d expects a directory path.
direct directory path : should be changed with a java file path or use **/*.java e.g. /home/abdullah/Desktop/WordCountTutorial/tutorial_classes/*.java
I'm having troubles with converting my javac command as used under windows (my libraries are placed within the lib folder, the source code within the src folder, and the compiled code should be placed within the bin folder):
javac -cp lib/\* -d bin src/\*.java
into the correct linux javac command. I have tried many variations including
javac -cp lib/* -d bin src/*.java
but that doesn't seem to work :
"invalid flag: lib/org.eclipse.paho.client.mqttv3-1.0.2.jar".
I am looking for a solution to this already quite some time, so any advice on this would be highly appreciated!
This is one of those odd things that happens when you don't put quotes around an argument.
Solution worked out in comments section: "lib/" instead of lib/
javac -cp "lib/*" -d bin src/*.java
The other issue was that ; is needed instead of : in Linux for classpaths.
I set up a folder containing a test java file that only contains the word "test". I want docker to compile it. To run it, I call
$ docker run -it -v ~/my/path/testpayload:/payload -w /payload test_docker javac -cp /usr/share/java/*:. *.java
However, I get the following error
javac: file not found: *.java
Usage: javac <options> <source files>
use -help for a list of possible options
If I explicitly state the name of the java file like so:
$ docker run -it -v ~/my/path/testpayload:/payload -w /payload test_docker javac -cp /usr/share/java/*:. TestPayload.java
It tries to compile and returns with the expected error:
TestPayload.java:1: error: reached end of file while parsing
test
^
1 error
I tried it again with the wildcard but without the classpath and it still doesn't work, which makes me think it's something with the wildcard, I googled but it seems to me like I'm using the wildcard correctly.
Thanks.
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
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