I ran the following command to compile a servlet called BeerSelect.java from HeadFirst Servlets and JSP book.
D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee>javac
-classpath /common/lib servlet-api.jar:classes: -d classes src/com/example/web/B
eerSelect.java
My servlet-api.jar is located in D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\common\lib
MESSAGE
javac: invalid flag: servlet-api.jar:classes:
Usage: javac <options> <source files> use -help for a list of possible options
Cannot understand how to fix this command and compile the servlet. Doing it for the first time new to servlets.
Then I changed the command to be
D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee\WEB-IN
F\src\com\example\web>javac -classpath "D:\Apache Tomcat\apache-tomcat-5.5.36\ap
ache-tomcat-5.5.36\common\lib\servlet-api.jar";classes BeerSelect.java
MESSAGE
BeerSelect.java:3: package com.example.model does not exist
import com.example.model.*;
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:15: cannot find symbol
symbol : class BeerExpert
location: class com.example.web.BeerSelect
BeerExpert be = new BeerExpert();
^
BeerSelect.java:32: cannot find symbol
symbol : variable out
location: class com.example.web.BeerSelect
out.println("<br>try: " + it.next());
^
4 errors
Why cannot it find the com.example.model package ?
IMAGE
It looks like you have three issues with your command: extra spaces, Unix-style pathnames, and missing additional Java source files. Try the following instead:
javac -classpath "D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\common\lib\servlet-api.jar";classes -d classes src\com\example\web\*.java src\com\example\model\*.java
I've removed extra spaces, converted Unix paths to Windows paths, changed the classpath separator from the Unix-style ':' to Windows-style ';', and added your other Java sources - compiling them all together should resolve your first three compiler errors.
As for the last compiler error, that appears to be a genuine source code error - try prepending System. to the out.println("<br>try: " + it.next()); line. (It can also be resolved by a static import, but that would be unconventional.)
D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee>javac -classpath "D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\common\lib\servlet-api.jar";"D:\Apache Tomcat\apache-tomcat-5.5.36\apache-tomcat-5.5.36\webapps\Coffee\WEB-INF\src" WEB-INF\src\com\example\web\BeerSelect.java
This command works and compiles the class BeerSelect.java.
Related
I am getting an error for below batch file.
cls
set classpath=C:\Program^ Files\salesforce.com\Data^ Loader\dataloader-29.0.0-uber.jar
set mainclass=com.salesforce.dataloader.process.ProcessRunner
set confdir=C:\Program^ Files\salesforce.com\Data^ Loader\Bkp\
if [%1]==[] goto error
call java -cp %classpath% -Dsalesforce.config.dir=%confdir% %mainclass% process.name=Product_vod__c sfdc.extractionSOQL="SELECT
Id,name FROM Product_vod__c where Id in %1"
goto end
:error
echo Error: missing date argument (must be in 'yyyy-mm-ddThh:mm:ssZ' format)
:end
Error
Could not find or load main class Files\salesforce.com\Data
Can someone please let me know the issue?
Thanks
You've got an unescaped Program Files somewhere in your classpath and its space breaks the classpath argument : the classpath stops at Program and java parses the following Files\salesforce.com\Data as the class it should execute.
You should enclose classpath fragments containing spaces with double-quotes.
I am using Sqoop to try import a sql server table into Hive. The connection string is working correctly but the import is failing. Below is the output. I am getting the same error if I try import into HDFS as well. Does anyone know what the issue might be?
[cloudera#ushydgnadipalvx sqoop]$ sqoop import --connect "jdbc:sqlserver://[server];username=[username];password=[password];database=[dbname]" --table [tablename] --hive-import
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
15/07/10 15:31:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.3-cdh4.7.0
15/07/10 15:31:41 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override
15/07/10 15:31:41 INFO tool.BaseSqoopTool: delimiters with --fields-terminated-by, etc.
15/07/10 15:31:41 INFO manager.SqlManager: Using default fetchSize of 1000
15/07/10 15:31:41 INFO tool.CodeGenTool: Beginning code generation
15/07/10 15:31:43 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM [SocialDatas] AS t WHERE 1=0
15/07/10 15:31:45 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/lib/hadoop-0.20-mapreduce
/tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java:206: cannot find symbol
symbol : method readString(java.io.DataInput)
location: class java.lang.String
this.Language = Text.readString(__dataIn);
^
/tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java:211: cannot find symbol
symbol : method readString(java.io.DataInput)
location: class java.lang.String
this.Platform = Text.readString(__dataIn);
^
/tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java:216: cannot find symbol
symbol : method readString(java.io.DataInput)
location: class java.lang.String
this.Text = Text.readString(__dataIn);
^
/tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java:257: cannot find symbol
symbol : method writeString(java.io.DataOutput,java.lang.String)
location: class java.lang.String
Text.writeString(__dataOut, Language);
^
/tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java:263: cannot find symbol
symbol : method writeString(java.io.DataOutput,java.lang.String)
location: class java.lang.String
Text.writeString(__dataOut, Platform);
^
/tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java:269: cannot find symbol
symbol : method writeString(java.io.DataOutput,java.lang.String)
location: class java.lang.String
Text.writeString(__dataOut, Text);
^
Note: /tmp/sqoop-cloudera/compile/0159bb09ed314f098b249cb4c7c97130/SocialDatas.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
6 errors
15/07/10 15:31:47 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: Error returned by javac
at org.apache.sqoop.orm.CompilationManager.compile(CompilationManager.java:217)
at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:97)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:396)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:506)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:222)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:231)
at org.apache.sqoop.Sqoop.main(Sqoop.java:240)
Errors in output shown above are due to hadoop jars not being in CLASSPATH. Try to import after setting proper CLASSPATH. Below is example for tcsh shell.
setenv CLASSPATH $HADOOP_HOME/lib/*:$CLASSPATH
The issue turned out to be that I had a column name called "Text" and that was causing the error. I fixed it by renaming my column.
I have a java applet (SetWatch.class) which I wish to modify. It only supports an offset of 30 minutes and I want 120. I'd like to parameterise the value eventually, but I'd settle for a hard code value as an interim step. I have decompiled it using the website www. showmycode. com. The class file and the resulting .java file are here:
http://www.edcint.co.nz/tmp/SetWatch/
I have programming skills but not java skills so I am unable to verify if the .java file looks good. So I before I modify it I thought I'd try and compile it.
I am running Fedora 19 and using java-1.7.0-openjdk.
I try a basic
javac SetWatch.java
Which gives:
SetWatch.java:65: error: cannot find symbol
javax.sound.sampled.DataLine.Info info = new javax.sound.sampled.DataLine.Info(javax/sound/sampled/SourceDataLine, audioformat);
^
symbol: variable javax
location: class SetWatch
SetWatch.java:65: error: cannot find symbol
javax.sound.sampled.DataLine.Info info = new javax.sound.sampled.DataLine.Info(javax/sound/sampled/SourceDataLine, audioformat);
^
symbol: variable sound
location: class SetWatch
SetWatch.java:65: error: cannot find symbol
javax.sound.sampled.DataLine.Info info = new javax.sound.sampled.DataLine.Info(javax/sound/sampled/SourceDataLine, audioformat);
^
symbol: variable sampled
location: class SetWatch
SetWatch.java:65: error: cannot find symbol
javax.sound.sampled.DataLine.Info info = new javax.sound.sampled.DataLine.Info(javax/sound/sampled/SourceDataLine, audioformat);
^
symbol: variable SourceDataLine
location: class SetWatch
4 errors
So I set about trying to find javax.sound.sampled.DataLine.Info.
I find javax/sound/sampled/DataLine$Info.class inside /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.5.0.fc19.i386/jre/lib/rt.jar. Close, maybe that will work?
javac -classpath /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.5.0.fc19.i386/jre/lib/rt.jar SetWatch.java
No. Same errors. So I try unzip /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.5.0.fc19.i386/jre/lib/rt.jar into /tmp (which does seem dodgy to me) and then try
javac -classpath /tmp/javax/sound/sampled SetWatch.java which gives different errors:
SetWatch.java:674: error: cannot access AudioFormat
AudioFormat audioformat;
^
bad class file: /tmp/javax/sound/sampled/AudioFormat.class
class file contains wrong class: javax.sound.sampled.AudioFormat
Please remove or make sure it appears in the correct subdirectory of the classpath.
This looks worse to me like it has sort of worked but caused other problems.
I know I only have javax/sound/sampled/DataLine$Info.class which is not exactly what I want. Where do I get javax.sound.sampled.DataLine.Info from?
I've grepped inside every file from the java RPMs looking for DataLine\.Info but I can not find it.
This is the problem when using a decompiler, you often get junk code in the resultant "source" file. The class literal argument has been mangled:
info =
new javax.sound.sampled.DataLine.Info(javax/sound/sampled/SourceDataLine,
audioformat);
^--------------------------------^
it should be
info =
new javax.sound.sampled.DataLine.Info(javax.sound.sampled.SourceDataLine.class,
audioformat);
Read: DataLine.Info javadoc
I downloaded the demo from http://www2.cs.tum.edu/projects/cup/
I got parser.java by command:
java -jar bin/java-cup-11a.jar cup/parser.cup
but when I compile parser.java by:
javac -classpath lib/java-cup-11a-runtime.jar parser.java
the result is:
cspro#Think:~/Desktop/template$ javac -classpath lib/*.jar -d . parser.java
parser.java:104: cannot find symbol
symbol : class Parser
location: class Example.parser
if (args.length==0) new Parser(new Scanner(System.in,sf),sf).parse();
^
parser.java:104: java_cup.runtime.Scanner is abstract; cannot be instantiated
if (args.length==0) new Parser(new Scanner(System.in,sf),sf).parse();
^
parser.java:105: cannot find symbol
symbol : class Parser
location: class Example.parser
else new Parser(new Scanner(new java.io.FileInputStream(args[0]),sf),sf).parse();
^
parser.java:105: java_cup.runtime.Scanner is abstract; cannot be instantiated
else new Parser(new Scanner(new java.io.FileInputStream(args[0]),sf),sf).parse();
^
Note: parser.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
4 errors
how to compile the parser.java ?
I have written a very simple file with specification shown below to to tokenize words:
%%
%class Lexer
%unicode
WORD = [^\r\n\t ]
%%
{WORD} {System.out.println("Word is:"+yytext());}
. {System.out.println("Bad character: "+ yytext());}
The following are the commands I run:
jflex hindi.jlex
javac Lexer.java
I get the following error:
Lexer.java:442: cannot find symbol
symbol : class Yytoken
location: class Lexer
public Yytoken yylex() throws java.io.IOException {
^
1 error
Any help appreciated.
On a additional note I checked the Lexer.java file and there was no main function in it. Is that the reason for this error.
If you want to check the lexer standalone(without a parser) then add the following to the user code section:
%standalone
Those working with byaccj and getting this error should add a %byaccj line instead of %standalone below the %class Lexer line