I am attempting to use the #Plugin annotation. Am following the example of FileAppender here.
However, java does not recognize it and instead I get
error: package org.apache.logging.log4j.plugins does not exist
Is there some jar I need to include? I already have the log4j jars log4j-api-2.14.0.jar and log4j-core-2.14.0.jar (as well as log4j-slf4j18-impl-2.14.0.jar).
How do I get the import working in order to use #Plugin?
It turned out the import line was different than it was for all the example code I was referencing.
I searched within the jar to check whether any Plugin classes were there, and noticed they had a different path than the import line in the examples.
> jar -tf .\log4j-core-2.14.0.jar | rg Plugin
org/apache/logging/log4j/core/config/plugins/util/PluginRegistry$PluginTest.class
org/apache/logging/log4j/core/config/plugins/util/PluginManager.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginAttributeVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor$PluginAliasesElementVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginCache.class
org/apache/logging/log4j/core/config/plugins/util/PluginBuilder.class
org/apache/logging/log4j/core/config/plugins/PluginBuilderAttribute.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginElementVisitor.class
org/apache/logging/log4j/core/config/PropertiesPlugin.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor$1.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginConfigurationVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginEntry.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginBuilderAttributeVisitor.class
org/apache/logging/log4j/core/config/plugins/visitors/AbstractPluginVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor$PluginElementVisitor.class
org/apache/logging/log4j/core/config/plugins/PluginNode.class
META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
org/apache/logging/log4j/core/config/plugins/visitors/PluginVisitor.class
org/apache/logging/log4j/core/config/plugins/PluginAttribute.class
org/apache/logging/log4j/core/config/plugins/PluginValue.class
org/apache/logging/log4j/core/appender/FailoversPlugin.class
org/apache/logging/log4j/core/config/plugins/PluginBuilderFactory.class
org/apache/logging/log4j/core/config/plugins/util/PluginType.class
org/apache/logging/log4j/core/config/plugins/util/PluginRegistry.class
org/apache/logging/log4j/core/config/plugins/Plugin.class
org/apache/logging/log4j/core/config/plugins/PluginAliases.class
org/apache/logging/log4j/core/config/plugins/PluginVisitorStrategy.class
org/apache/logging/log4j/core/config/AppendersPlugin.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginVisitors.class
org/apache/logging/log4j/core/config/LoggersPlugin.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginValueVisitor.class
org/apache/logging/log4j/core/config/plugins/visitors/PluginNodeVisitor.class
org/apache/logging/log4j/core/config/plugins/processor/PluginProcessor.class
org/apache/logging/log4j/core/config/plugins/PluginConfiguration.class
org/apache/logging/log4j/core/config/plugins/PluginFactory.class
org/apache/logging/log4j/core/config/plugins/PluginElement.class
org/apache/logging/log4j/core/config/ScriptsPlugin.class
I changed the import line from
import org.apache.logging.log4j.plugins.Plugin;
to
import org.apache.logging.log4j.core.config.plugins.Plugin;
and then the annotations were recognized.
Related
In jdoc 8.0.1 I see com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer
But I can't import it:
import com.atlassian.jira.issue.fields.renderer.wiki.AtlassianWikiRenderer;
> .... package com.atlassian.jira.issue.fields.renderer.wiki does not exist
How can I use AtlassianWikiRenderer.render(...) in my own render?
The same with com.atlassian.jira.issue.fields.renderer.text.DefaultTextRenderer
Works for me. You need to have jira-core uncommented out in your pom.xml file
I am trying to import a jar file. My file "Test.java" contains the line:
"import org.jfugue.*;"
When I run the command "javac -classpath .:jfugue-5.0.9.jar Test.java", I get the error "package org.jfugue does not exist". How do I fix this?
Note: I am using a Mac machine.
Actually if you inspect the jar file "jfugue-5.0.9.jar", There're no any Class files in the package "org.jfugue.". Instead it contains some sub packages such as org.jfugue.devices., org.jfugue.integration., org.jfugue.parser. etc.
Try something like this,
import org.jfugue.devices.*;
public class Hello {
public static void main (String[] args) {
System.out.println("Hi");
}
}
Starting point
You want to compile code using the contents of a jar file, specifically "jfugue-5.0.9.jar", and you have a "Test" class with an import statement, like this:
import org.jfugue.*;
public class Test {
}
If you compile that code, you get an error like this:
% javac -classpath .:jfugue-5.0.9.jar Test.java
Test.java:1: error: package org.jfugue does not exist
import org.jfugue.*;
^
1 error
What's going on?
You're doing the right steps, mostly, but the import statement isn't correct. Syntax-wise, it's fine, but it does not align with the contents of the jar file. The structure of the jar contents (which you can see by running: jar tf jfugue-5.0.9.jar) shows that there is a directory for "org/jfugue/", but there are no classes or interfaces there; it's just a directory.
Below is a view of the first 9 lines of jar contents, sorted. It shows several directories without file
contents – "org/" and "org/jfugue/" – but "org/jfugue/devices/" for example has four files present.
% jar tf jfugue-5.0.9.jar | sort | head -9
META-INF/
META-INF/MANIFEST.MF
org/
org/jfugue/
org/jfugue/devices/
org/jfugue/devices/MidiParserReceiver.class
org/jfugue/devices/MusicReceiver.class
org/jfugue/devices/MusicTransmitterToParserListener.class
org/jfugue/devices/MusicTransmitterToSequence.class
So if you were to change the import statement to "org.jfugue.devices.*" – which would match those four files
("MusicReceiver", etc) – then compilation would work fine (no errors).
import org.jfugue.devices.*;
public class Test {
}
% javac -classpath .:jfugue-5.0.9.jar Test.java
%
Solution
Following
JLS 7.5.1,
you can import each specific class one by one, such as:
import org.jfugue.devices.MidiParserReceiver;
import org.jfugue.devices.MusicReceiver;
import org.jfugue.devices.MusicTransmitterToParserListener;
import org.jfugue.devices.MusicTransmitterToSequence;
Or following
JLS 7.5.2,
you can import all classes and interfaces matching a wildcard pattern (so
long as there are actually classes or interfaces matching that pattern)
such as:
import org.jfugue.devices.*;
It's not allowed to import a subpackage, so "import org.jfugue;" (without the .* wildcard) would not work
(see Example 7.5.1-3 No Import of a Subpackage in JLS).
I am trying to filter an excel sheet using POI class and to set the filter when i used this :
CTAutoFilter sheetFilter = my_sheet.getCTWorksheet().getAutoFilter();
CTFilterColumn myFilterColumn = sheetFilter.insertNewFilterColumn(0);
got below mentioned error on "CTFilterColumn".
Multiple markers at this line
- The method insertNewFilterColumn(int) from the type CTAutoFilter refers to the
missing type CTFilterColumn
- The type org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFilterColumn
cannot be resolved. It is indirectly referenced from required .class files
- CTFilterColumn cannot be resolved to a type
Entire code :
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.*;
import org.apache.poi.ss.usermodel.ComparisonOperator;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter;
public class Test1 {
public static void main(String[] args) {
try {
//To read values and enable auto filter
FileInputStream fileIn = new FileInputStream("./XMLs/Test001.xlsx");
XSSFWorkbook my_workbook = new XSSFWorkbook(fileIn);
XSSFSheet my_sheet = my_workbook.getSheet("Sheet1");
CTAutoFilter sheetFilter = my_sheet.getCTWorksheet().getAutoFilter();
CTFilterColumn myFilterColumn = sheetFilter.insertNewFilterColumn(0);
Instead of this "import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter;" i tried import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
But CTFilterColumn is not even listed in suggestions. Please help.
Is it because of some missing jar files, please help.
Promoting a comment to an answer
This is covered in this Apache POI FAQ Entry - I'm using the poi-ooxml-schemas jar, but my code is failing with "java.lang.NoClassDefFoundError: org/openxmlformats/schemas/something". The key section is:
There are two jar files available, as described in the components overview section. The full jar of all of the schemas is ooxml-schemas-1.3.jar, and it is currently around 15mb. The smaller poi-ooxml-schemas jar is only about 4mb. This latter jar file only contains the typically used parts though.
Many users choose to use the smaller poi-ooxml-schemas jar to save space. However, the poi-ooxml-schemas jar only contains the XSDs and classes that are typically used, as identified by the unit tests. Every so often, you may try to use part of the file format which isn't included in the minimal poi-ooxml-schemas jar. In this case, you should switch to the full ooxml-schemas-1.3.jar. Longer term, you may also wish to submit a new unit test which uses the extra parts of the XSDs, so that a future poi-ooxml-schemas jar will include them.
So, short term you need to swap out your small poi-ooxml-schemas jar for the full ooxml-schemas-1.3 jar. Longer term, if you submit a unit test to Apache POI which uses these extra classes, it'll be included in a future small schema jar.
Maven artifact details for the full schema are covered here on the Apache POI site
I have java file at location.
/root/Desktop/software/UIMA/yagogit/yodaqa/src/main/java/cz/brmlab/yodaqa/analysis/question/FocusGenerator.java
This file is part of entire project - FocusGenerator.java
it is importing couple of classes from UIMA and few other packages. (I already configure UIMA on my system)
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
import org.apache.uima.UimaContext;
import org.apache.uima.resource.ResourceInitializationException;
import cz.brmlab.yodaqa.model.TyCor.LAT;
import cz.brmlab.yodaqa.provider.OpenNlpNamedEntities;
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS;
import de.tudarmstadt.ukp.dkpro.core.api.ner.type.NamedEntity;
While executing entire projects following readme file, it works well. But I wanted to test each individual program, like one mentioned above. When I try to compile using javac it gives error, cannot find symbol as below
ATByFocus.java:77: cannot find symbol
symbol : class ImplicitQLAT
location: class cz.brmlab.yodaqa.analysis.question.LATByFocus
addFocusLAT(jcas, focus, "amount", null, 33914, 0.0, new ImplicitQLAT(jcas));
^
LATByFocus.java:83: cannot find symbol
symbol : class LAT
location: class cz.brmlab.yodaqa.analysis.question.LATByFocus
addFocusLAT(jcas, focus, text, pos, 0, 0.0, new LAT(jcas));
and so on.
What is correct way to execute this file. I tried it importing in eclipse to, but in eclipse too it could not be imported as project.
It is difficult to build pieces of YodaQA in isolation. I think it's much simpler to just work within YodaQA, but create your custom main class which will directly call the FocusGenerator or any other class you want.
To add another main class and execute it, you will need to add another gradle target. See build.gradle for a few examples already: tsvgs, biocrftrain, etc.
I have two different packages inside of my application. The trouble I am having is the packages wont recognize each other.
package sticyface.androidgames.framework.impl;
package sticyface.androidgames.framework;
when I try to import a java file from one to the other I receive an error under stickyface. It says "The import sticyface cannot be resolved.Example
import stickyface.androidgames.framework.Input.TouchEvent;
What am I forgetting to do?
Check your filesystem, you may have created two different structures on the filesystem (which the package definition mirrors.
stickyface.androidgames.framework.Input.TouchEvent -> {src dir}/stickyface/androidgames/framework/Input/TouchEvent.class
So if TouchEvent.class is not in that directory then it can't be imported in. You can also try replacing TouchEvent with * in the import line just in case, that'll import in what needs dynamically.