Need Some help. Though there are lot of different answers available and also I tried them but couldn't make it work. I intsalled hadoop locally in my mac os and when I tried compiling the java programs I got the following errors. I know the problem is with the setting up the correct class path, but in may case providing the class path didn't make it work. I have installed hadoop under /usr/local/Cellar/hadoop/1.2.1/libexec
I have my java home set to export JAVA_HOME="$(/usr/libexec/java_home)"
and class path set to export HADOOP_CLASSPATH=${HADOOP_HOME}/bin:${JAVA_HOME}/bin:${PATH}
but still getting the below errors. Any suggestions for the setting up the correct class path would be appreciated.
LineIndexer.java:6: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.LongWritable;
^
LineIndexer.java:7: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.Text;
^
LineIndexer.java:8: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.FileInputFormat;
^
LineIndexer.java:9: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.FileOutputFormat;
^
LineIndexer.java:10: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.FileSplit;
^
LineIndexer.java:11: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.JobClient;
^
LineIndexer.java:12: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.JobConf;
^
LineIndexer.java:13: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.MapReduceBase;
^
LineIndexer.java:14: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.Mapper;
^
LineIndexer.java:15: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.OutputCollector;
^
LineIndexer.java:16: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.Reducer;
^
LineIndexer.java:17: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.Reporter;
^
LineIndexer.java:21: cannot find symbol
symbol : class MapReduceBase
location: class LineIndexer
public static class LineIndexMapper extends MapReduceBase
^
LineIndexer.java:22: cannot find symbol
symbol : class Mapper
location: class LineIndexer
implements Mapper {
^
LineIndexer.java:22: cannot find symbol
symbol : class LongWritable
location: class LineIndexer
implements Mapper {
^
LineIndexer.java:22: cannot find symbol
symbol : class Text
location: class LineIndexer
implements Mapper {
^
Looks like your classpath is wrong, try this instead:
javac -classpath /usr/local/cellar/hadoop-1.2.1/hadoop-core-1.2.1.jar
Or redefine your HADOOP_HOME env variable to be /usr/local/cellar/hadoop-1.2.1
Related
I am trying to run my java class by command line. When I executed throw an error:
PS C:\Users\mcruz\Desktop\diff-java> javac src/main/Main.java
src\main\Main.java:8: error: package com.google.gson does not exist
import com.google.gson.Gson;
^
src\main\Main.java:10: error: package object does not exist
import object.Command;
^
src\main\Main.java:11: error: package object does not exist
import object.Environments;
^
src\main\Main.java:12: error: package object does not exist
import object.MetadataType;
^
src\main\Main.java:13: error: package object does not exist
import object.PackageBuild;
^
src\main\Main.java:14: error: package object does not exist
import object.ReadFile;
^
src\main\Main.java:16: error: package object does not exist
import object.Resource;
I don't know if this command detects the libraries that I implement in the project or what I need to do to solve this problem. (My libraries are in a folder with the name lib.)
I read in another post that I can use javac -cp to add the classpath but, I need to add more than one library.
Example :
javac -cp lib/error_prone_annotations-2.11.0.jar;lib/gson-2.9.0.jar;lib/logger-1.24.0.jar;lib/logger-slf4j-1.24.0.jar;lib/logger-spi-1.24.0.jar;lib7safe-logging-1.24.0.jar;lib/slf4j-api-1.7.31.jar src/main/Main.java
package main;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import com.google.gson.Gson;
import object.Command;
import object.Environments;
import object.MetadataType;
import object.PackageBuild;
import object.ReadFile;
import object.Resource;
public class Main { ........
This question already has answers here:
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
(18 answers)
Closed 2 years ago.
We have a school project to make a mod for the popular video game Minecraft. I decided to make my own version of the 1.9.4 client. When I decompile it and put into an intelliJ project a few errors come. Most of them are easy to find out and can be fixed by reimporting a few files, but 1 stayed behind. The error was a single line of code in the DragonFightManager Class. Code was: this.gateways.addAll((Collection<? extends Integer>) ContiguousSet.create(Range.<C>closedOpen(valueOf, 20, DiscreteDomain.integers())));. When I hit run/decompile the error: Error:(106, 106) java: cannot find symbol symbol: variable valueOf location: class net.minecraft.world.end.DragonFightManager<C>, comes. I did a bit of research and find that the "Cannot Find Symbol" error means I haven't used the variable correctly, in this case the valueOf variable. I thought maybe it was an import that I am missing so here are all the imports
import java.io.*;
import com.google.common.collect.*;
import net.minecraft.block.state.BlockWorldState;
import net.minecraft.block.state.pattern.BlockMatcher;
import net.minecraft.block.state.pattern.BlockPattern;
import net.minecraft.block.state.pattern.FactoryBlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.entity.boss.EntityDragon;
import net.minecraft.entity.boss.dragon.phase.PhaseList;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityEndPortal;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntitySelectors;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.BossInfo;
import net.minecraft.world.BossInfoServer;
import net.minecraft.world.WorldServer;
import net.minecraft.world.biome.BiomeEndDecorator;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.feature.WorldGenEndGateway;
import net.minecraft.world.gen.feature.WorldGenEndPodium;
import net.minecraft.world.gen.feature.WorldGenSpikes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.annotation.Nullable;
import java.util.*;
import java.util.function.Predicate;
import static java.lang.Integer.*;
So what is the fix to this error and if you need more detail please say so in the comments.
EXTRA INFO**
Tutorial I used for the valueOf. And for some reason when I import java.io.*; it doesn't have a color like any of the other imports, so maybe that's it. Idk:/
That error means that you're using a variable (valueOf) that has never been declared nor initialized.
Maybe there was a problem while decompiling, but I googled it and instead of valueOf there should be written Integer.valueOf(0)
I know that this question was already asked thousand times, but I still can't fully understand the point of the problem, especially in my case. So, I have simple project with dependency of TestNG and Selenium Java libraries, and I have these libraries installed globally, so my project just import them from "global" scope.
So to solve the problem I should add that global folder to my classpath ? Or this in not right from the beginning and I should not use libraries globally in projects ?
C:\Users\Yaroslav\IdeaProjects\GoogleSearchTest\src\main\java>javac GoogleSearchTest.java
GoogleSearchTest.java:1: error: package org.openqa.selenium does not exist
import org.openqa.selenium.By;
^
GoogleSearchTest.java:2: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebDriver;
^
GoogleSearchTest.java:3: error: package org.openqa.selenium does not exist
import org.openqa.selenium.WebElement;
^
GoogleSearchTest.java:4: error: package org.openqa.selenium.chrome does not exist
import org.openqa.selenium.chrome.ChromeDriver;
^
GoogleSearchTest.java:5: error: package org.testng.annotations does not exist
import org.testng.annotations.BeforeClass;
^
GoogleSearchTest.java:6: error: package org.testng.annotations does not exist
import org.testng.annotations.Parameters;
^
GoogleSearchTest.java:7: error: package org.testng.annotations does not exist
import org.testng.annotations.Test;
^
GoogleSearchTest.java:12: error: cannot find symbol
private static WebDriver driver;
^
symbol: class WebDriver
location: class GoogleSearchTest
GoogleSearchTest.java:14: error: cannot find symbol
#BeforeClass
^
symbol: class BeforeClass
location: class GoogleSearchTest
GoogleSearchTest.java:23: error: cannot find symbol
#Test
^
symbol: class Test
location: class GoogleSearchTest
GoogleSearchTest.java:24: error: cannot find symbol
#Parameters("queryText")
^
symbol: class Parameters
location: class GoogleSearchTest
GoogleSearchTest.java:17: error: cannot find symbol
driver = new ChromeDriver();
^
symbol: class ChromeDriver
location: class GoogleSearchTest
GoogleSearchTest.java:26: error: cannot find symbol
WebElement searchField = driver.findElement(By.cssSelector("#lst-ib"));
^
symbol: class WebElement
location: class GoogleSearchTest
GoogleSearchTest.java:26: error: cannot find symbol
WebElement searchField = driver.findElement(By.cssSelector("#lst-ib"));
^
symbol: variable By
location: class GoogleSearchTest
GoogleSearchTest.java:28: error: cannot find symbol
WebElement searchButton = driver.findElement(By.name("btnK"));
^
symbol: class WebElement
location: class GoogleSearchTest
GoogleSearchTest.java:28: error: cannot find symbol
WebElement searchButton = driver.findElement(By.name("btnK"));
^
symbol: variable By
location: class GoogleSearchTest
16 errors
GoogleSearchTest.java
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
public class GoogleSearchTest {
private static WebDriver driver;
#BeforeClass
public void setup () {
System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\chromedriver_win32\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.google.com/");
}
#Test
#Parameters("queryText")
public void doSearch(String queryText) {
WebElement searchField = driver.findElement(By.cssSelector("#lst-ib"));
searchField.sendKeys(queryText);
WebElement searchButton = driver.findElement(By.name("btnK"));
searchButton.click();
}
}
I finally understand how it should be done.
So, to compile class and then run TestNG test I done this:
javac -cp C:\Users\Yaroslav\IdeaProjects\GoogleSearchTest\lib\* GoogleSearchTest.java
java -cp C:\Users\Yaroslav\IdeaProjects\GoogleSearchTest\src\main\java\;C:\Users\Yaroslav\IdeaProjects\GoogleSearchTest\lib\* org.testng.TestNG testng.xml
More detailed, in first line to compile class there should be a following command template:
javac -cp "full path to libs folder, where project libraries located" "name of class to compile"
And for second line, which run TestNG test, template is:
java -cp "full path to folder where testng.xml file located";"full path to libs folder, where project libraries located" "testNG filename with extension"
And this is very tiresome, as you can see. I should learn proper way to run similar tests without headache ...
P.S. After all, I just learn Maven and there is no need for these commands now )
I am very new to java.
Can somebody help why I am getting error: cannot find symbol error.
I have a class User.java which I am able to compile with success. User.class gets created in the same dir.
When I try to compile Another class UserDao.java which used User, it reports cannot find symbol error as stated.
vm#vm:~/UserManagement/com/tutorialspoint$ pwd
/home/vm/UserManagement/com/tutorialspoint
vm#vm:~/UserManagement/com/tutorialspoint$ ls
User.class UserDao.java User.java UserManagement.war UserService.java web.xml
vm#vm:~/UserManagement/com/tutorialspoint$ javac UserDao.java
UserDao.java:15: error: cannot find symbol
public List<User> getAllUsers(){
^
symbol: class User
location: class UserDao
UserDao.java
package com.tutorialspoint;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
public class UserDao {
public List<User> getAllUsers(){
List<User> userList = null;
try {
Please help.
Thanks.
You did not set a classpath, which defaults to be the current directory. So javac can't find the .class file for User.
Please take the effort to read the classpath documentation.
The solution here is to either compile all classes at once:
javac UserDao.java User.java UserService.java
Or set the classpath to the root of your packages:
javac -cp "/home/vm/UserManagement" UserDao.java
I am trying trying to import java.lang.Math in Java on Eclipse and am getting the error in the title. Here is the beginning of my code:
import java.lang.Math;
package test1;
This error is popping up under "package test1;"
The package statement must be first in the file, before anything, even imports:
package hw1;
import java.lang.Math;
Plus, you don't need to import java.lang.Math, or anything in java.lang for that matter.
The JLS, Chapter 7 says:
A compilation unit automatically has access to all types declared in
its package and also automatically imports all of the public types
declared in the predefined package java.lang.
Place the package declaration before the import statement
package hw1;
import java.lang.Math;
The import statement itself is unnecesary as all classes in java.lang are imported by default.
Read Creating a Package