Getting Error while executing the below command
dz> run app.package.manifest jakhar.aseem.diva
C:\Program Files\Java\jdk1.8.0_65\bin\javac.exe -cp C:\Program Files\drozer\lib\drozer\lib\android.jar XmlAssetReader.java
javac: invalid flag: Files\Java\jdk1.8.0_65\bin\javac.exe
Usage: javac <options> <source files>
use -help for a list of possible options
Error whilst compiling the Java sources.
The problem is that the program run doesn't understand the space in Program Files:
C:\Program Files\Java\jdk1.8.0_65\bin\javac.exe -cp C:\Program Files\drozer\lib\drozer\lib\android.jar XmlAssetReader.java
javac: invalid flag: Files\Java\jdk1.8.0_65\bin\javac.exe
It calls javac, which sees the -cp flag (for classpath). But javac doesn't realize that what follows is a single directory. It thinks the part from Files\ onward is a new flag... that it doesn't know.
If you created this program run yourself, then the easiest solution is adapt that source - put double-quotes around the argument. So you'd get:
-cp "C:\Program Files\drozer\lib\drozer\lib\android.jar"
Alternatively, on a Windows machine, you may be able to use Progra~1 as a shorthand for this directory. But off the top of my head that won't work on every Windows machine anymore.
Related
I'm new at Java, and I've just recently installed it and set the environmental variables.
But when I try to compile something, it says:
javac: file not found: BoleanTest.java
Usage: javac <options> <source files>
use -help for a list of possible options
And when I open JVM it says:
No local JVM's were detected, not even the jvm running this instance of java mission control.
Help please, thank you.
(A photo of the error as shown on the screen)
Make sure that you are in the same location as your .java file in your terminal. It seems that you are in the wrong directory.
Or
you can execute javac command from a different location as your java file like this: javac C:\Program Files\SomeDirectory\Test.java
In command prompt the currently active folder is C:\Program Files\Notepad++
However your file is created on your Desktop (C:\Users\Alban Selmanaj\Desktop\BoleanTest.java).
As a starting point try the following command before attempting to run javac:
cd %USERPROFILE%\Desktop
Please confirm if it helps or not.
In terminal you are in C:\Program Files... and your file is created at C:\Users\.... You are obviously missing your paths here
I downloaded a sample code written in java that has multiple jar files and java files. I am not a Java programmer so I am having a hard time compiling the code. Here's my attempt:
javac -classpath lib/*.jar src/*.java
However this is what I get:
javac: invalid flag: lib/dom4j-1.6.1.jar
Usage: javac <options> <source files>
use -help for a list of possible options
What's wrong with my approach and how can I compile the code? ALl the jar files are located in the lib folder, and the java files in the src folder.
You need to stop the shell from globbing the wild-card in lib/*.jar by escaping it.
Also, you need to remove the .jar suffix ... because that's how classpath wildcards work; see Oracle's "Setting the classpath" document.
So ...
javac -classpath lib/\* src/*.java
Using an IDE is another option. However, if all you want to do is compile and run, then downloading and installing and learning to use an IDE is overkill (IMO). And the flipside is that it is good for an IDE-using Java programmer to also understand how to compile and run from the shell prompt ...
old post, but thought below details help,
you can specify jar files by separating by ; in windows and : in unix
Eg: (windows)
javac -cp first.jar;second.jar;third.jar YourClass.java
(unix)
javac -cp first.jar:second.jar:third.jar YourClass.java
Source: https://gullele.com/pass-all-the-jars-in-classpath-when-compiling-java/
I am trying to compile a Java servlet which uses multiple external jars. Javac recognises the first jar, but then spits out errors that it can't find the following jars. When I swap the order, it still recognises the first, but none after. The command line I am using;
javac -classpath ~/servlet/servlet-api-2.3.jar:~/servlet/gson-2.2.2.jar:~/servlet/mysql-connector-java-5.1.22-bin.jar ~/servlet/dataExchange.java ~/servlet/dbUserConnect.java ~/servlet/dbTTConnect.java -d $TOMCAT_HOME
As you can see I am trying to use the servlet jar, Googles GSON (JSON), MySQL & Oracle Jars.
If you need any other information just ask.
Thanks in advance!
At least one mistake:
Usage: javac <options> <source files>
Your command line is:
Usage: javac <options> <source files> <options>
Try this:
javac -classpath ~/servlet/servlet-api-2.3.jar:~/servlet/gson-2.2.2.jar:~/servlet/mysql-connector-java-5.1.22-bin.jar -d $TOMCAT_HOME ~/servlet/dataExchange.java ~/servlet/dbUserConnect.java ~/servlet/dbTTConnect.java
The problem is the use of the ~ character throughout the path. Only the instance at the beginning of the option will be expanded.
I'm trying to compile a Java 1.6 program. The following compiles without error:
# javac -cp /path/to/ojdbc6.jar:. MyJavaProgram.java
But adding a flag causes this error:
# javac -cp /path/to/ojdbc6.jar:. -Doracle.jdbc.SetFloatAndDoubleUseBinary=true MyJavaProgram.java -help
javac: invalid flag: -Doracle.jdbc.SetFloatAndDoubleUseBinary=true
Usage: javac <options> <source files>
use -help for a list of possible options
Is the flag not supported? I added the -help but it didn't give any more info (did I add it in the right place above?).
The options must come before the source files (as indicated in your question): remove the -help.
-D option specify properties and are passed to the JVM (java) and are not compile time flags. From java -help:
-D<name>=<value>
set a system property
To view the list of available compiler options execute:
javac -help
I am trying to compile my source code from the Windows 7 command prompt. I have added the directory in which my *.java file is located to the classpath. Yet, I still get this error:
C:\Users\Alex>javac HelloThere.java
javac: file not found: HelloThere.java
Usage: javac <options> <source files>
use -help for a list of possible options
I'm very confused as to why this happens because if I navigate to the folder where this file is located, it will compile. However, this is not a satisfactory solution since I intend on compiling JUnit tests directly from the command line as well.
Other solutions I have attempted:
C:\Users\Alex>javac -classpath "C:\Users\Alex\AndroidProject\UnitTest\src" HelloThere.java
javac: file not found: HelloThere.java
Usage: javac <options> <source files>
use -help for a list of possible options
I do not think this has ANYTHING to do with typos.
Why can't I compile my project like this?
The CLASSPATH variable is not used by javac to find where your source code lives. Use the -sourcepath arg to javac instead.
Save yourself a lot of time and manual typing and use a build tool like Apache Ant or Maven.
You don't want to use classpath, that tells the compiler where to find externally referenced .class files used by your file. You want to use -sourcepath which tells javac where your .java files may be hiding.