JAVA error: package com/... does not exist - java

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

Related

JSP could not find available java class

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.

Import millis() in processing library

I'm trying to write a library called "Visione" in Processing using the processing-library-template here.
Unfortunately Eclipse gives me the following error:
[javac] long lastIpCameraRead = millis();
[javac] ^
[javac] symbol: method millis()
[javac] location: class Visione
I noticed the errors also occurs in most of the basics Processing functions like delay(), stroke(), etc.
This is the list of the imports:
import processing.core.*;
import gab.opencv.*;
import ipcapture.*;
import g4p_controls.* ;
import processing.video.*;
import java.awt.* ;
import java.util.*;
Thank you!
If you're in a class other than your main sketch, you can't access Processing's functions directly.
Instead, you'd probably want to pass a PApplet reference into your class, and use that to call Processing's functions. Something like this:
public class MyClass{
public MyClass(PApplet sketch){
long time = sketch.millis();
}
}
Then in your sketch code, you would use the this keyword to pass in a self-reference to the sketch:
void setup(){
size(500, 500);
new MyClass(this);
}

How can I compile this basic Spring application without IDE?

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

How to consider maven dependency in java program compilation via command line

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

schemagen for nested objects without ant task

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

Categories

Resources