Tomcat ClassPath Not Working For Javac Compilation - java

I am trying to compile a servlet on my tomcat classpath and it will not work even though I believe I have the right command. I want to use json utils for parsing and the obvious servlets api. However, I cannot get the package to be ever found. I reinstalled java, which is java 11, and I also reinstalled Tomcat, which is Tomcat 10. This is on a Windows machine.
This is what I do in the console and what gets outputted.
D:\Tomcat\apache-tomcat-10.0.2\webapps\helloservlet\WEB-INF>javac -cp
".;D:/Tomcat/apache-tomcat-10.0.2/lib/servlet-api.jar;D:/Tomcat/apache-tomcat-
10.0.2/lib/tomcat-util.jar;.;" -d classes src\mypkg\HelloServlet.java -source
1.8 -target 1.8
warning: [options] bootstrap class path not set in conjunction with -source 8
src\mypkg\HelloServlet.java:9: error: cannot find symbol
public class HelloServlet extends HttpServlet {
^
symbol: class HttpServlet
src\mypkg\HelloServlet.java:11: error: cannot find symbol
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
symbol: class HttpServletRequest
location: class HelloServlet
src\mypkg\HelloServlet.java:11: error: cannot find symbol
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
symbol: class HttpServletResponse
location: class HelloServlet
src\mypkg\HelloServlet.java:12: error: cannot find symbol
throws IOException, ServletException {
^
symbol: class ServletException
location: class HelloServlet
src\mypkg\HelloServlet.java:4: error: package javax.servlet does not exist
import javax.servlet.*;
^
src\mypkg\HelloServlet.java:5: error: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
src\mypkg\HelloServlet.java:6: error: package org.apache.json.util does not exist
import org.apache.json.util.*;
^
src\mypkg\HelloServlet.java:10: error: method does not override or implement a method from a supertype
#Override
^
src\mypkg\HelloServlet.java:15: error: cannot find symbol
JSONObject j = new JSONObject(request);
^
symbol: class JSONObject
location: class HelloServlet
src\mypkg\HelloServlet.java:15: error: cannot find symbol
JSONObject j = new JSONObject(request);
^
symbol: class JSONObject
location: class HelloServlet
10 errors
1 warning

Related

Execution failed for task ':compileJava'. - Issue 3 in this series

Before this question gets closed for already being asked, as far as I can see it is a vague and common error so this is different from other questions.
I fixed the error in my previous post by installing a slightly different version of Forge, but have now reached Step 5 of this tutorial. When I use .\gradlew build with the example mod, everything seems to work fine (although I cannot find the console output) But when I edit the mod to how the author describes, I get many errors.
The example mod:
package com.example.examplemod;
import net.minecraft.init.Blocks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
#Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
public class ExampleMod
{
public static final String MODID = "examplemod";
public static final String VERSION = "1.0";
#EventHandler
public void init(FMLInitializationEvent event)
{
// some example code
System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName());
}
}
How I changed it, following the tutorial:
package com.example.examplemod;
import net.minecraft.init.Blocks;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
#Mod(modid = ExampleMod.MODID, version = ExampleMod.VERSION)
public class ExampleMod
{
public static final String MODID = "examplemod";
public static final String VERSION = "1.1";
#EventHandler
public void init(FMLInitializationEvent event)
{
Block amethystOre = new ModBlock(Material.rock, "amethystOre");
GameRegistry.registerBlock(amethystOre, "amethystOre");
}
private class ModBlock extends Block
{
public ModBlock(Material material, String blockName)
{
super(material);
this.setBlockName(blockName);
this.setBlockTextureName(MODID + ":" + blockName);
this.setCreativeTab(CreativeTabs.tabBlock);
}
}
}
When I run .\gradlew build, I get:
#################################################
ForgeGradle 1.2-SNAPSHOT-fb514d3
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava UP-TO-DATE
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:21: error: cannot find symbol
private class ModBlock extends Block
^
symbol: class Block
location: class ExampleMod
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:23: error: cannot find symbol
public ModBlock(Material material, String blockName)
^
symbol: class Material
location: class ExampleMod.ModBlock
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:17: error: cannot find symbol
Block amethystOre = new ModBlock(Material.rock, "amethystOre");
^
symbol: class Block
location: class ExampleMod
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:17: error: cannot find symbol
Block amethystOre = new ModBlock(Material.rock, "amethystOre");
^
symbol: variable Material
location: class ExampleMod
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:18: error: cannot find symbol
GameRegistry.registerBlock(amethystOre, "amethystOre");
^
symbol: variable GameRegistry
location: class ExampleMod
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:26: error: cannot find symbol
this.setBlockName(blockName);
^
symbol: method setBlockName(String)
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:27: error: cannot find symbol
this.setBlockTextureName(MODID + ":" + blockName);
^
symbol: method setBlockTextureName(String)
C:\Users\benji\MinecraftWorkspace\forge-1.7.10-10.13.4.1558-1.7.10-src\build\sources\java\com\example\examplemod\ExampleMod.java:28: error: cannot find symbol
this.setCreativeTab(CreativeTabs.tabBlock);
^
symbol: variable CreativeTabs
location: class ExampleMod.ModBlock
8 errors
1 warning
:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
I don't know a whole lot about Java (I just started learning it) but I would assume that copying the tutorial character-for-character should result in an error-free program. Apparently not.
Looking at the error output on the compiler, the first error is 'The import net cannot be resolved' (line 3) I don't know why though.
Any help is much appreciated,
Ben
(From comment)
Import are wrong. You should use net.minecraft.* not net.minecraft.init.* :
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;

How to resolve “package org.openqa.selenium.winium does not exist” error?

I am using Winium tool for automation. I have included below jar files into the classpath of my project,
selenium-server-standalone-3.14.0.jar
testng-7.0.0-beta1.jar
winium-elements-desktop-0.1.0-1.jar
winium-elements-desktop-0.2.0-1.jar
Java installed version : 1.8
When I try to compile the program, I am getting below errors.
D:\Incidents\Winium_213716\TestProjects\winium-desktop-sample-project-master\winium-desktop-sample-project-master\src\main\java>javac sampleTest.java
sampleTest.java:44: error: package org.openqa.selenium.winium does not exist
import org.openqa.selenium.winium.DesktopOptions;
^
sampleTest.java:45: error: package org.openqa.selenium.winium does not exist
import org.openqa.selenium.winium.WiniumDriver;
^
sampleTest.java:52: error: cannot find symbol
DesktopOptions options= new DesktopOptions();
^
symbol: class DesktopOptions
location: class sampleTest
sampleTest.java:52: error: cannot find symbol
DesktopOptions options= new DesktopOptions();
^
symbol: class DesktopOptions
location: class sampleTest
sampleTest.java:55: error: cannot find symbol
WiniumDriver driver=new WiniumDriver(new
URL("http://localhost:9999"),options);
^
symbol: class WiniumDriver
location: class sampleTest
sampleTest.java:55: error: cannot find symbol
WiniumDriver driver=new WiniumDriver(new
URL("http://localhost:9999"),options);
^
symbol: class WiniumDriver
location: class sampleTest
6 errors
Below is my java Code
import java.io.IOException;
import java.net.URL;
import org.openqa.selenium.winium.DesktopOptions;
import org.openqa.selenium.winium.WiniumDriver;
import org.testng.annotations.Test;
public class sampleTest
{
#Test
public void test() throws IOException{
DesktopOptions options= new DesktopOptions();
options.setApplicationPath("C:\\WINDOWS\\system32\\notepad.exe");
try{
WiniumDriver driver=new WiniumDriver(new
URL("http://localhost:9999"),options);
driver.findElementByClassName("Edit").sendKeys("This is
sample test");
driver.close();
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
You need Winium web driver jar for the mentioned imports
winium-webdriver-0.1.0-1-sources.jar This jar file is required. This only contains the package "org.openqa.selenium.winium" which is missing in your case.
Try adding it as maven dependency if this is a maven project or search for the below dependency in maven central and download as zip. extract and add to build path of your project=> Java build path -> libraries.
<dependency>
<groupId>com.github.2gis.winium</groupId>
<artifactId>winium-webdriver</artifactId>
<version>0.1.0-1</version>
</dependency>

Biojava: Package import errors

The following code:
import org.biojava.bio.structure.ResidueNumber;
import org.biojava.bio.structure.Structure;
import org.biojava.bio.structure.io.PDBFileReader;
import org.biojava3.protmod.structure.ProteinModificationIdentifier;
public class Test3 {
public static void main(String[] args) {
try {
PDBFileReader reader = new PDBFileReader();
reader.setAutoFetch(true);
// identify all modifications from PDB:1CAD and print them
String pdbId = "1CAD";
Structure struc = reader.getStructureById(pdbId);
Set<ModifiedCompound> mcs = identifyAllModfications(struc);
for (ModifiedCompound mc : mcs) {
System.out.println(mc.toString());
}
// identify all phosphosites from PDB:3MVJ and print them
pdbId = "3MVJ";
struc = reader.getStructureById(pdbId);
List<ResidueNumber> psites = identifyPhosphosites(struc);
for (ResidueNumber psite : psites) {
System.out.println(psite.toString());
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
...results in the following stream of error messages:
C:\Users\CaitlinG>javac Test3.java
Test3.java:1: error: package org.biojava.bio.structure does not exist
import org.biojava.bio.structure.ResidueNumber;
^
Test3.java:2: error: package org.biojava.bio.structure does not exist
import org.biojava.bio.structure.Structure;
^
Test3.java:3: error: package org.biojava.bio.structure.io does not exist
import org.biojava.bio.structure.io.PDBFileReader;
^
Test3.java:4: error: package org.biojava4.protmod.structure does not exist
import org.biojava4.protmod.structure.ProteinModificationIdentifier;
^
Test3.java:9: error: cannot find symbol
PDBFileReader reader = new PDBFileReader();
^
symbol: class PDBFileReader
location: class Test3
Test3.java:9: error: cannot find symbol
PDBFileReader reader = new PDBFileReader();
^
symbol: class PDBFileReader
location: class Test3
Test3.java:14: error: cannot find symbol
Structure struc = reader.getStructureById(pdbId);
^
symbol: class Structure
location: class Test3
Test3.java:15: error: cannot find symbol
Set<ModifiedCompound> mcs = identifyAllModfications(struc)
^
symbol: class Set
location: class Test3
Test3.java:15: error: cannot find symbol
Set<ModifiedCompound> mcs = identifyAllModfications(struc)
^
symbol: class ModifiedCompound
location: class Test3
Test3.java:16: error: cannot find symbol
for (ModifiedCompound mc : mcs) {
^
symbol: class ModifiedCompound
location: class Test3
Test3.java:23: error: cannot find symbol
List<ResidueNumber> psites = identifyPhosphosites(struc);
^
symbol: class List
location: class Test3
Test3.java:23: error: cannot find symbol
List<ResidueNumber> psites = identifyPhosphosites(struc);
^
symbol: class ResidueNumber
location: class Test3
Test3.java:24: error: cannot find symbol
for (ResidueNumber psite : psites) {
^
symbol: class ResidueNumber
location: class Test3
13 errors
I have manually downloaded every jar file for Biojava 4.2.4 and stored each of them in a desktop folder (included in my classpath), listed each individually on my classpath, and stored both in C:\program files\java\jdk1.8.0_112\jre\lib\ext
and C:\program files\java\jdk1.8.0_112\jre\ext yet the errors are not resolved.
I'm using a Windows 10 machine, Java JDK8_112, and BioJava 4.2.4
Any help would be appreciated.
Thank you.

Compilation error when using Apache Thrift

I tried to run a thrift server and client program that was given in the thrift website and I got the below errors.Can anyone please help me out with the errors.
coding can be found in : https://thrift.apache.org/tutorial/java
naren#naren:~/Desktop$ javac javaserver.java
javaserver.java:16: error: class JavaServer is public, should be declared in a file named JavaServer.java
public class JavaServer {
^
javaserver.java:1: error: package org.apache.thrift.server does not exist
import org.apache.thrift.server.TServer;
^
javaserver.java:2: error: package org.apache.thrift.server.TServer does not exist
import org.apache.thrift.server.TServer.Args;
^
javaserver.java:3: error: package org.apache.thrift.server does not exist
import org.apache.thrift.server.TSimpleServer;
^
javaserver.java:4: error: package org.apache.thrift.server does not exist
import org.apache.thrift.server.TThreadPoolServer;
^
javaserver.java:5: error: package org.apache.thrift.transport does not exist
import org.apache.thrift.transport.TSSLTransportFactory;
^
javaserver.java:6: error: package org.apache.thrift.transport does not exist
import org.apache.thrift.transport.TServerSocket;
^
javaserver.java:7: error: package org.apache.thrift.transport does not exist
import org.apache.thrift.transport.TServerTransport;
^
javaserver.java:8: error: package org.apache.thrift.transport.TSSLTransportFactory does not exist
import org.apache.thrift.transport.TSSLTransportFactory.TSSLTransportParameters;
^
javaserver.java:11: error: package tutorial does not exist
import tutorial.*;
^
javaserver.java:12: error: package shared does not exist
import shared.*;
^
javaserver.java:18: error: cannot find symbol
public static CalculatorHandler handler;
^
symbol: class CalculatorHandler
location: class JavaServer
javaserver.java:20: error: package Calculator does not exist
public static Calculator.Processor processor;
^
javaserver.java:45: error: package Calculator does not exist
public static void simple(Calculator.Processor processor) {
^
javaserver.java:58: error: package Calculator does not exist
public static void secure(Calculator.Processor processor) {
^
javaserver.java:24: error: cannot find symbol
handler = new CalculatorHandler();
^
symbol: class CalculatorHandler
location: class JavaServer
javaserver.java:25: error: package Calculator does not exist
processor = new Calculator.Processor(handler);
^
javaserver.java:47: error: cannot find symbol
TServerTransport serverTransport = new TServerSocket(9090);
^
symbol: class TServerTransport
location: class JavaServer
javaserver.java:47: error: cannot find symbol
TServerTransport serverTransport = new TServerSocket(9090);
^
symbol: class TServerSocket
location: class JavaServer
javaserver.java:48: error: cannot find symbol
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
^
symbol: class TServer
location: class JavaServer
javaserver.java:48: error: cannot find symbol
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
^
symbol: class TSimpleServer
location: class JavaServer
javaserver.java:48: error: cannot find symbol
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
^
symbol: class Args
location: class JavaServer
javaserver.java:61: error: cannot find symbol
TSSLTransportParameters params = new TSSLTransportParameters();
^
symbol: class TSSLTransportParameters
location: class JavaServer
javaserver.java:61: error: cannot find symbol
TSSLTransportParameters params = new TSSLTransportParameters();
^
symbol: class TSSLTransportParameters
location: class JavaServer
javaserver.java:65: error: cannot find symbol
TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
^
symbol: class TServerTransport
location: class JavaServer
javaserver.java:65: error: cannot find symbol
TServerTransport serverTransport = TSSLTransportFactory.getServerSocket(9091, 0, null, params);
^
symbol: variable TSSLTransportFactory
location: class JavaServer
javaserver.java:66: error: cannot find symbol
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
^
symbol: class TServer
location: class JavaServer
javaserver.java:66: error: cannot find symbol
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
^
symbol: class TSimpleServer
location: class JavaServer
javaserver.java:66: error: cannot find symbol
TServer server = new TSimpleServer(new Args(serverTransport).processor(processor));
^
symbol: class Args
location: class JavaServer
29 errors
naren#naren:~/Desktop$
As far as we can deduce from what you've shown, there's a couple of things that go wrong:
There seems to be an issue with your invocation of javac, it is missing a classpath that refers to the Apache Thrift library. You can specify the classpath using the -cp parameter. Make sure it points to the current directory, the Thrift libraries and any other libraries you might be using.
Your class JavaServer should be declared in a file named JavaServer.java (exactly as the compiler error says). Apparently, it's called javaserver.java, which is not the same (at least not on non-Windows platforms).
Sample .thrift files attached to official web tutorial have some errors (July 2015, v0.9.x).
Inconsequences in sample struct/classes etc, sample doesn't compile in few languages.
Version of this files in official tar.gz are good.

Compile java program on linux with external libraries

I am trying to compile a java file using SMACK for the XMPP libraries. In the folder of the java file i have included a Libs directory including all the *.jar files for SMACK but when i try
javac filename
i get this output:
SmackCcsClient.java:6: error: package org.jivesoftware.smack does not exist
import org.jivesoftware.smack.ConnectionConfiguration;
^
SmackCcsClient.java:7: error: package org.jivesoftware.smack.ConnectionConfiguration does not exist
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
^
SmackCcsClient.java:8: error: package org.jivesoftware.smack does not exist
import org.jivesoftware.smack.ConnectionListener;
^
SmackCcsClient.java:9: error: package org.jivesoftware.smack does not exist
import org.jivesoftware.smack.PacketInterceptor;
^
SmackCcsClient.java:10: error: package org.jivesoftware.smack does not exist
import org.jivesoftware.smack.PacketListener;
^
SmackCcsClient.java:11: error: package org.jivesoftware.smack does not exist
import org.jivesoftware.smack.XMPPConnection;
^
SmackCcsClient.java:12: error: package org.jivesoftware.smack does not exist
import org.jivesoftware.smack.XMPPException;
^
SmackCcsClient.java:13: error: package org.jivesoftware.smack.filter does not exist
import org.jivesoftware.smack.filter.PacketTypeFilter;
^
SmackCcsClient.java:14: error: package org.jivesoftware.smack.packet does not exist
import org.jivesoftware.smack.packet.DefaultPacketExtension;
^
SmackCcsClient.java:15: error: package org.jivesoftware.smack.packet does not exist
import org.jivesoftware.smack.packet.Message;
^
SmackCcsClient.java:16: error: package org.jivesoftware.smack.packet does not exist
import org.jivesoftware.smack.packet.Packet;
^
SmackCcsClient.java:17: error: package org.jivesoftware.smack.packet does not exist
import org.jivesoftware.smack.packet.PacketExtension;
^
SmackCcsClient.java:18: error: package org.jivesoftware.smack.provider does not exist
import org.jivesoftware.smack.provider.PacketExtensionProvider;
^
SmackCcsClient.java:19: error: package org.jivesoftware.smack.provider does not exist
import org.jivesoftware.smack.provider.ProviderManager;
^
SmackCcsClient.java:20: error: package org.jivesoftware.smack.util does not exist
import org.jivesoftware.smack.util.StringUtils;
^
SmackCcsClient.java:21: error: package org.json.simple does not exist
import org.json.simple.JSONValue;
^
SmackCcsClient.java:22: error: package org.json.simple.parser does not exist
import org.json.simple.parser.ParseException;
^
SmackCcsClient.java:23: error: package org.xmlpull.v1 does not exist
import org.xmlpull.v1.XmlPullParser;
^
SmackCcsClient.java:52: error: cannot find symbol
XMPPConnection connection;
^
symbol: class XMPPConnection
location: class SmackCcsClient
SmackCcsClient.java:53: error: cannot find symbol
ConnectionConfiguration config;
^
symbol: class ConnectionConfiguration
location: class SmackCcsClient
SmackCcsClient.java:306: error: cannot find symbol
public void connect(String username, String password) throws XMPPException {
^
symbol: class XMPPException
location: class SmackCcsClient
SmackCcsClient.java:58: error: cannot find symbol
class GcmPacketExtension extends DefaultPacketExtension {
^
symbol: class DefaultPacketExtension
location: class SmackCcsClient
SmackCcsClient.java:77: error: cannot find symbol
public Packet toPacket() {
^
symbol: class Packet
location: class SmackCcsClient.GcmPacketExtension
SmackCcsClient.java:70: error: method does not override or implement a method from a supertype
#Override
^
SmackCcsClient.java:78: error: cannot find symbol
return new Message() {
^
symbol: class Message
location: class SmackCcsClient.GcmPacketExtension
SmackCcsClient.java:117: error: cannot find symbol
GCM_NAMESPACE, new PacketExtensionProvider() {
^
symbol: class PacketExtensionProvider
location: class SmackCcsClient
SmackCcsClient.java:116: error: cannot find symbol
ProviderManager.getInstance().addExtensionProvider(GCM_ELEMENT_NAME,
^
symbol: variable ProviderManager
location: class SmackCcsClient
SmackCcsClient.java:145: error: cannot find symbol
Packet request = new GcmPacketExtension(jsonRequest).toPacket();
^
symbol: class Packet
location: class SmackCcsClient
SmackCcsClient.java:276: error: cannot find symbol
return JSONValue.toJSONString(message);
^
symbol: variable JSONValue
location: class SmackCcsClient
SmackCcsClient.java:294: error: cannot find symbol
return JSONValue.toJSONString(message);
^
symbol: variable JSONValue
location: class SmackCcsClient
SmackCcsClient.java:307: error: cannot find symbol
config = new ConnectionConfiguration(GCM_SERVER, GCM_PORT);
^
symbol: class ConnectionConfiguration
location: class SmackCcsClient
SmackCcsClient.java:308: error: cannot find symbol
config.setSecurityMode(SecurityMode.enabled);
^
symbol: variable SecurityMode
location: class SmackCcsClient
SmackCcsClient.java:319: error: cannot find symbol
XMPPConnection.DEBUG_ENABLED = true;
^
symbol: variable XMPPConnection
location: class SmackCcsClient
SmackCcsClient.java:321: error: cannot find symbol
connection = new XMPPConnection(config);
^
symbol: class XMPPConnection
location: class SmackCcsClient
SmackCcsClient.java:324: error: cannot find symbol
connection.addConnectionListener(new ConnectionListener() {
^
symbol: class ConnectionListener
location: class SmackCcsClient
SmackCcsClient.java:353: error: cannot find symbol
connection.addPacketListener(new PacketListener() {
^
symbol: class PacketListener
location: class SmackCcsClient
SmackCcsClient.java:397: error: cannot find symbol
}, new PacketTypeFilter(Message.class));
^
symbol: class PacketTypeFilter
location: class SmackCcsClient
SmackCcsClient.java:397: error: cannot find symbol
}, new PacketTypeFilter(Message.class));
^
symbol: class Message
location: class SmackCcsClient
SmackCcsClient.java:400: error: cannot find symbol
connection.addPacketInterceptor(new PacketInterceptor() {
^
symbol: class PacketInterceptor
location: class SmackCcsClient
SmackCcsClient.java:405: error: cannot find symbol
}, new PacketTypeFilter(Message.class));
^
symbol: class PacketTypeFilter
location: class SmackCcsClient
SmackCcsClient.java:405: error: cannot find symbol
}, new PacketTypeFilter(Message.class));
^
symbol: class Message
location: class SmackCcsClient
SmackCcsClient.java:447: error: cannot find symbol
} catch (XMPPException e) {
^
symbol: class XMPPException
location: class SmackCcsClient
42 errors
how do i compile this correctly? is there some extra command needed for the smack library?
UPDATE:
i have created the following folder structure:
root
->bin
->src
->lib
I have tried compiling with different javac commands like:
javac -d bin -sourcepath src -cp :lib src/SmackCcsClient.java
I have tried various variations but i keep getting the same output every time.
UPDATE 2:
running the command:
javac -d bin -sourcepath src -cp lib/*.jar src/SmackCcsClient.java
gave the following output:
javac: invalid flag: lib/smack-android-4.1.1-javadoc.jar
Usage: javac <options> <source files>
use -help for a list of possible options
I am following different tutorials but i cannot figure out how to do this correctly.
A correct command would be (assuming all needed .jar files are actually in the lib/ folder, and all sources are in the src/ folder):
javac -d bin -sourcepath src -cp $(find lib -iname *.jar | xargs | tr " " ":") src/SmackCcsClient.java
The tricky part (within $( )) is building something like a.jar:b.jar:c.jar (no spaces, separated by :) from all the jar-files in the lib/ folder. Your attempt using -cp lib/*.jar failed because there were spaces instead of : separating the jar-files, and javac thought that the second jar-file it found was actually java source that you wanted to compile. And then complained that it did not know how to compile jar-files.
A simpler version (that relies on there being no sub-directories in lib/) is
javac -d bin -sourcepath src -cp $(echo lib/*.jar | tr " " ":") src/SmackCcsClient.java

Categories

Resources