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.
Related
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;
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 done some investigation, and got strange results.
My classes:
Test.java:
package com.company;
import com.company.data.Byte;
import com.company.data.Class;
import com.company.zata.Long;
import com.company.zata.Short;
import com.company.data.*;
import com.company.zata.*;
public class Test {
Object o1 = new Class();
Object o2 = new SomeClass();
Object o3 = new AppleClass();
Object o4 = new Byte();
Object o5 = new Long();
Object o6 = new Short();
Object o7 = new BetaClass();
}
All clases is simple, for test. For example one of all:
package com.company.data;
public class Class {
public Class() {
}
}
Tree of classes:
I try organize imports for Intellij IDEA, Eclipse and Netbeans and got results:
Intellij IDEA before organize imports:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.zata.Long;
import com.company.zata.Short;
import com.company.data.*;
import com.company.zata.*;
Intellij IDEA after organize imports:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.data.*;
import com.company.zata.*;
import com.company.zata.Long;
import com.company.zata.Short;
Eclipse before organize imports:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.zata.Long;
import com.company.zata.Short;
import com.company.data.*;
import com.company.zata.*;
Eclipse after organize imports:
import com.company.data.*;
import com.company.data.Byte;
import com.company.data.Class;
import com.company.zata.*;
import com.company.zata.Long;
import com.company.zata.Short;
NetBeans before organize imports:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.zata.Long;
import com.company.zata.Short;
import com.company.data.*;
import com.company.zata.*;
NetBeans after organize imports:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.data.*;
import com.company.zata.*;
import com.company.zata.Long;
import com.company.zata.Short;
Eclipse sorting imports alphabetical.
How sorting imports Intellij IDEA and NetBeans - I do not understand.
I expected for Intellij IDEA and NetBeans this results:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.data.*;
import com.company.zata.Long;
import com.company.zata.Short;
import com.company.zata.*;
Why Intellij Idea and Netbeans sort imports in this way?
The point is: why do you expect that different tools behave the very same way in the first place?!
You see, these different IDEs are using different rules that determine how imports are organized; and of course, those rules can be tweaked.
See this example how to make IntelliJ behave like eclipse; and over here for how to edit the Netbeans setup for this stuff.
This is only a wild guess of mine.
What I saw is that IntelliJ and Netbeans try to move the imports as little as possible. See how the two .* imports stick together? I think that is because before it organized the imports, they stuck together as well.
The two editors see that if they just move the last two lines up and make the third and fourth lines replace the position of the last two lines, the package names will be sort in alphabetical order! So that's what they did.
Unfortunately, I cannot test this myself. But if you change the initial position of the .* imports, the result of organizing the imports might change.
Try organizing this:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.zata.Long;
import com.company.data.*;
import com.company.zata.Short;
import com.company.zata.*;
If my guess is correct, the editor will swap the third and fourth lines.
I got results with Intellij IDEA 15.0.1.
If we try to organize imports with latest version Intellij IDEA, we got result:
import com.company.data.Byte;
import com.company.data.Class;
import com.company.data.*;
import com.company.zata.Long;
import com.company.zata.Short;
import com.company.zata.*;
I think it is correct sorting.
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 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.