Command line with multiple libraries - java

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 { ........

Related

package org.ofbiz.clientmanagementservices does not exist

I have this class that I want to import into another class that is outside the previous class folder.
So, I have a GoogleDriveAPI class, which I want to import to DocumentServices class.
on top of my GoogleDriveAPI class there is this line
package org.ofbiz.ClientManagementServices;
but when I try to import it to DocumentServices class with this line below
import org.ofbiz.clientmanagementservices.GoogleDriveAPI;
I get this error below,
error: package org.ofbiz.clientmanagementservices does not exist
[javac17] import org.ofbiz.clientmanagementservices.GoogleDriveAPI;
What might be the problem with my import because I am 100% sure I am doing the right thing?
Java packages are cas sensitive.
You should change the import to :
import org.ofbiz.ClientManagementServices.GoogleDriveAPI;

Java - Error:(106, 106) java: cannot find symbol symbol: variable valueOf location: class net.minecraft.world.end.DragonFightManager<C> [duplicate]

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)

Symbol not found even when referenced class exist

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

Hadoop ClassPath Single Node Cluster Mac OS

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

How do i get the java.net.URLConnection or the Hashtable from a class file?

How do i get the classes from the import list, or where do i find the imported class files. for example
import game.sprites.PlayerSprite;
import java.applet.Applet;
import java.awt.*;
import java.io.*;
import java.net.URL;
import java.util.Vector;
import litecom.Trace;
import litecom.gfxe.LoaderTarget2;
import litecom.gfxe.Timer;
import litecom.scoreclient2.ScoreClient2;
any idea how to get those java. files?
You don't. The import statements are not preserved in the bytecode. When you compile Java sources to class files (bytecode), the compiler inserts the fully qualified name of the classes which are referenced.

Categories