Errors in good syntax after using new machine [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have imported project to my new machine (to eclipse) and it threw 88 errors even that on previous machine it was working good. here are the types of errors:
MINUTES cannot be resolved or is not a field
Syntax error
Method not applicable to arguments
isEmpty() undefined
And when I check it all of syntax is good etc.
Anyone had similar problem?
Here's code which throws an exception (MINUTES cannot be resolved or is not a field )
try {
TimeUnit.MINUTES.sleep(Config.DOCS_CHECK_INTERVAL);
} catch (InterruptedException e) {
log.error("Exception", e);
}
Imports:
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.security.cert.X509Certificate;
import java.util.HashSet;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import com.ikubasienki.core.Config;

All of your errors suggest that you are using an outdated Java Version. For example, in Java 5, there was no TimeUnit.MINUTES: https://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/TimeUnit.html. It has been added in Java 6.
Assumed that you are calling isEmpty() on a String Object, the same is true: String.isEmpty() has been added in Java 6: https://docs.oracle.com/javase/6/docs/api/java/lang/String.html#isEmpty(), hence you would get an isEmpty() undefined error when building the project with Java 5.
Please check the settings of the "JRE System Library" you are using to build the project in Eclipse:
Verify that the path shown for the jar files matches the java runtime you want to use.
If that still does not help, create a new Project in Eclipse with a simple class like
package com.example;
public class Simple {
public static void main(String[] args) {
System.err.println(System.getProperty("java.version"));
System.err.println("".isEmpty());
}
}
and run it. The output should be something like
1.7.0_80
true
Another common source of errors is the Compiler Compliance Level setting of your project:
However, this would not explain the "undefined symbol" errors since it affects the language level only (e.g. whether enum or generics are allowed). It might explain your syntax error, though.

Make sure your custom jre in eclipse points to jre folder (if you're using jde make sure twice it's not ponting to jde but to jre inside jde!!)!

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)

SQUARE cannot be resolved to a variable in Processing/Eclipse

I have a problem with the following code:
parent.strokeCap(SQUARE);
I tried importing these:
import processing.core.PApplet;
import processing.core.PGraphics;
import processing.core.PShape;
import processing.core.PConstants;
import processing.core.PShapeSVG;
import processing.core.PGraphicsJava2D;
import processing.core.PStyle;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
But the problem persists. Do I have to make another import? I tried to find what value SQUARE represents but was unable to find any info about what it should contain.
note that you're not writing "Processing", you're writing Java, with all the regular Java formalisms and requirements, with some of your imports simply being the Processing API library. If you need a library constant, PConstants.SQUARE will get you there.

Import "imports" in eclipse - Java

I have several java files in a package and all of them have the same import blocks e.g :
package org.ezim.core;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import org.ezim.core.Ezim;
import org.ezim.core.EzimDtxSemantics;
import org.ezim.core.EzimLogger;
import org.ezim.ui.EzimFileOut;
import org.ezim.ui.EzimMain;
It looks awful having the same batches of code in each file and i want to refactor it.
I was wondering if its possible to put all these imports in a single java file then use a single line in all the other java files to call them.
Its like the extend function for classes (for variables) , but i want one for the imports.
Thanks
No. That isn't possible. What is possible is not using imports at all, instead you can use fully qualified class names like
org.ezim.core.Ezim ezim = new org.ezim.core.Ezim(); // <-- not import needed.
You can always use * sign to import multiple classes from one package, but thus watch for name clashes.

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