I executed my java file like this:
javac -cp ".:/root/Desktop/karim/software/UIMA/yagogit/yodaqa/gradle/wrapper/gradle-wrapper.jar" LATByFocus.java
which gives error like:
LATByFocus.java:5: package org.apache.uima does not exist
import org.apache.uima.UimaContext;
^
LATByFocus.java:6: package org.apache.uima.analysis_engine does not exist
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
^
LATByFocus.java:7: package org.apache.uima.fit.component does not exist
import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
^
LATByFocus.java:8: package org.apache.uima.fit.util does not exist
import org.apache.uima.fit.util.JCasUtil;
^
....
LATByFocus.java:36: cannot find symbol
symbol: class JCasAnnotator_ImplBase
public class LATByFocus extends JCasAnnotator_ImplBase {
^
LATByFocus.java:37: cannot find symbol
symbol : class Logger
location: class cz.brmlab.yodaqa.analysis.question.LATByFocus
final Logger logger = LoggerFactory.getLogger(LATByFocus.class);
^
LATByFocus.java:39: cannot find symbol
symbol : class UimaContext
location: class cz.brmlab.yodaqa.analysis.question.LATByFocus
public void initialize(UimaContext aContext) throws ResourceInitializationException {
^
LATByFocus.java:39: cannot find symbol
symbol : class ResourceInitializationException
......
So I wanted to try considering pom.xml along with jar file in command line - pom.xml
Is it possible?
I am trying to execute these files https://github.com/brmson/yodaqa/tree/master/src/main/java/cz/brmlab/yodaqa/analysis/question
in project : yodaqan
Related
I created a simple tic-tac-toe game, and put some functions on another package, so i can import them on my Main function.
When i run on eclipse IDE, i have no problem, but when i try run on windows CMD i get the following error: console log error
Here is my folder structure: folder structure
initial code of Main class, with imports:
package com.github.vitucomment.main;
import java.io.IOException;
import java.util.Map;
import com.github.vitucomment.players.PlayersFunctions;
import com.github.vitucomment.utils.BoardFunctions;
import com.github.vitucomment.utils.GameRulesFunctions;
import com.github.vitucomment.utils.ScoreFunctions;
public class Main {
Console log error:
C:\Users\victo\eclipse-workspace\Java-JogoDaVelha\src\com\github\vitucomment\main>java Main.java
Main.java:6: error: package com.github.vitucomment.players does not exist
import com.github.vitucomment.players.PlayersFunctions;
^
Main.java:7: error: package com.github.vitucomment.utils does not exist
import com.github.vitucomment.utils.BoardFunctions;
^
Main.java:8: error: package com.github.vitucomment.utils does not exist
import com.github.vitucomment.utils.GameRulesFunctions;
^
Main.java:9: error: package com.github.vitucomment.utils does not exist
import com.github.vitucomment.utils.ScoreFunctions;
^
Main.java:82: error: cannot find symbol
public static PlayersFunctions playersFunctions() {
^
symbol: class PlayersFunctions
location: class Main
Main.java:86: error: cannot find symbol
public static ScoreFunctions scoreFunctions() {
^
symbol: class ScoreFunctions
location: class Main
Main.java:90: error: cannot find symbol
public static BoardFunctions boardFunctions() {
^
symbol: class BoardFunctions
location: class Main
Main.java:94: error: cannot find symbol
public static GameRulesFunctions gameRulesFunctions() {
^
symbol: class GameRulesFunctions
location: class Main
Main.java:17: error: cannot find symbol
PlayersFunctions playersFunctions = playersFunctions();
^
symbol: class PlayersFunctions
location: class Main
Main.java:83: error: cannot find symbol
return new PlayersFunctions();
^
symbol: class PlayersFunctions
location: class Main
Main.java:87: error: cannot find symbol
return new ScoreFunctions();
^
symbol: class ScoreFunctions
location: class Main
Main.java:91: error: cannot find symbol
return new BoardFunctions();
^
symbol: class BoardFunctions
location: class Main
Main.java:95: error: cannot find symbol
return new GameRulesFunctions();
^
symbol: class GameRulesFunctions
location: class Main
13 errors
error: compilation failed
I don't know how to fix it, before change to packages it was working without problems.
CMD run project
make a file x.bat
copy Code change you config
#echo on
#title E:\projectPath
#set dir_path=E:\libPath
#setlocal EnableDelayedExpansion
#for %%i in (%dir_path%\*.jar,%dir_path%\lib\*.jar) do (
#set other_path=!other_path!;%%i
)
set classpath= %other_path%
#java package.Main
I used following code to call the java class from the JSP page.
<%String something=com.Package1.PrintInPicture.workingFunction(recentData);%>
I have package named as "com.Package1" as well as class and method named as "PrintInPicture" and "workingFunction(Stirng data)" respectively in that package. This is shown in code below:
package com.package1;
public class PrintInPicture {
static int width, height;
public static String workingFunction(String img_name) throws IOException{
}
But my JSP page is showing following error in the code which I have shown above:
cannot find symbol
symbol: class PrintInPicture
location: package com.Package1
Please, Help me to solve this error.
This is my directory layout:
~ koraytugay$ ls -1 biz/tugay/hellospring/
Bike.java
Car.java
Vehicle.java
VehicleApp.java
VehicleService.java
beans.xml
So I am in the root folder and my .java files are in biz/tugay/hellospring/
Code for VehicleApp:
package biz.tugay.hellospring;
/* User: koray#tugay.biz Date: 29/06/15 Time: 15:16 */
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class VehicleApp {
public static void main(String[] args) {
ApplicationContext applicationContext
= new ClassPathXmlApplicationContext("biz/tugay/hellospring/beans.xml");
VehicleService vehicleService = (VehicleService) applicationContext.getBean("vehicleService");
vehicleService.driver();
}
}
and VehicleService:
package biz.tugay.hellospring;
/* User: koray#tugay.biz Date: 29/06/15 Time: 15:10 */
public class VehicleService {
private Vehicle vehicle;
public void setVehicle(Vehicle vehicle) {
this.vehicle = vehicle;
}
public void driver(){
System.out.println(vehicle.drive());
}
}
Also in my home directory I have the following jar files:
~ koraytugay$ ls -1 *.jar
spring-aop-3.2.5.RELEASE.jar
spring-beans-3.2.5.RELEASE.jar
spring-context-3.2.5.RELEASE.jar
spring-security-core-3.2.5.RELEASE.jar
I tried several variations however I was not successful with any of them. One example:
~ koraytugay$ javac -cp .:/biz/tugay/hellospring biz/tugay/hellospring/VehicleApp.java
biz/tugay/hellospring/VehicleApp.java:4: error: package org.springframework.context does not exist
import org.springframework.context.ApplicationContext;
^
biz/tugay/hellospring/VehicleApp.java:5: error: package org.springframework.context.support does not exist
import org.springframework.context.support.ClassPathXmlApplicationContext;
^
biz/tugay/hellospring/VehicleApp.java:10: error: cannot find symbol
ApplicationContext applicationContext
^
symbol: class ApplicationContext
location: class VehicleApp
biz/tugay/hellospring/VehicleApp.java:11: error: cannot find symbol
= new ClassPathXmlApplicationContext("biz/tugay/hellospring/beans.xml");
^
symbol: class ClassPathXmlApplicationContext
location: class VehicleApp
4 errors
I have the .jar files in the folder I am executing javac. Why the compiler is unable to find ClassPathXmlApplicationContext ?
you either need to specify every jar
java -cp ./spring-aop-3.2.5.RELEASE.jar ; ./spring-beans-3.2.5.RELEASE.jar ;./spring-context-3.2.5.RELEASE.jar ; ./spring-security-core-3.2.5.RELEASE.jar
or use a wild card
java -cp *.jar; /otherpath
but thats only works with java 6 up
Can't find a solution to this problem.
Guitar2.java:
public class Guitar2
{
private String serialNumber;
public Guitar2(String serialNumber)
{
this.serialNumber = serialNumber;
}
public String getSerialNumber()
{
return serialNumber;
}
}
Inv2.java:
import java.util.List;
import java.util.LinkedList;
public class Inv2
{
private List guitars;
public Inv2()
{
guitars = new LinkedList();
}
public void addGuitar(String serialNumber)
{
Guitar2 guitar = new Guitar2(serialNumber);
guitars.add(guitar);
}
}
Both files are in the same directory, both are 755 and the directory is in the classpath. I get the error message:
[machine]me # directory $ javac Inventory.java
Inventory.java:18: cannot find symbol
symbol : class Guitar
location: class Inventory
Guitar guitar = new Guitar();
^
Inventory.java:18: cannot find symbol
symbol : class Guitar
location: class Inventory
Guitar guitar = new Guitar();
^
2 errors
I read that if a file is in the same directory, classes from it can be used in other files in the same directory without any import statements. What's the problem here?
POST EDIT Output when using the above code:
[me]machine # ricks $ javac Inv2.java
Note: Inv2.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
I get the .class files of both .java files.
Run javac Guitar.java
and only then (after it has been compiled and a Guitar.class was created) run javac Inventory.java
Try to compile Guitar.java first. then run your cmd . or try this : javac *.java
Make sure both classes have the same package. Even if they are in the same directory, a different package could cause this problem. Type the same package or use an import and then try compiling with javac *.java
I have the following class structure:
#XmlRootElement
public class A{
private String s;
private B b;
//getter and setter
}
#XmlRootElement
public class B{
private String ss;
//getter and setter
}
How to use schemagen to generate schema for class A ?
I am able to generate schema for class B as:
schemagen B.java
at cmd , but when I use same for class A , i.e.:
schemagen A.java
I got following error:
Problem encountered during annotation processing;
see stacktrace below for more information.
java.lang.NullPointerException
.
.
.
A.java:14: cannot find symbol
symbol : class B
location: class beans.A
public B getB() {
^
A.java:18: cannot find symbol
symbol : class B
location: class beans.A
public void setB(B b) {
^
A.java:22: cannot find symbol
symbol : class B
location: class beans.A
private B b;
^
3 errors
I found the sollution :
We need to specify classpath and all the internal beans also.
Following command worked:
schemagen -cp . A.java B.java