How to properly compile this file using javac - java

I have the following file called Test.Java the code of which is
package example25;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.Iterator;
import org.jibx.runtime.BindingDirectory;
import org.jibx.runtime.IBindingFactory;
import org.jibx.runtime.IMarshallingContext;
import org.jibx.runtime.IUnmarshallingContext;
import org.jibx.runtime.JiBXException;
public class Test
{
public static void main(String[] args)
{
try
{
// unmarshal customer information from file
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
FileInputStream in = new FileInputStream("D:\\Java Libraries\\jibx\\dwcode2\\starter.xml");
Order order = (Order)uctx.unmarshalDocument(in, null);
// compute the total amount of the order
float total = 0.0f;
for (Iterator<Item> iter = order.getItemList().iterator(); iter.hasNext();)
{
Item item = iter.next();
total += item.getPrice() * item.getQuantity();
}
order.setTotal(new Float(total));
// marshal object back out to file (with nice indentation, as UTF-8)
IMarshallingContext mctx = bfact.createMarshallingContext();
mctx.setIndent(2);
FileOutputStream out = new FileOutputStream("c:\\out.xml");
mctx.setOutput(out, null);
mctx.marshalDocument(order);
System.out.println("Processed order with " + order.getItemList().size() + " items and total value " + total);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
System.exit(1);
} catch (JiBXException e)
{
e.printStackTrace();
System.exit(1);
}
}//end main
}//end class
Here is how i am trying to compile this file and the output that i get
C:\jibx\tutorial>javac example25\Test.java
example25\Test.java:8: error: package org.jibx.runtime does not exist
import org.jibx.runtime.BindingDirectory;
^
example25\Test.java:9: error: package org.jibx.runtime does not exist
import org.jibx.runtime.IBindingFactory;
^
example25\Test.java:10: error: package org.jibx.runtime does not exist
import org.jibx.runtime.IMarshallingContext;
^
example25\Test.java:11: error: package org.jibx.runtime does not exist
import org.jibx.runtime.IUnmarshallingContext;
^
example25\Test.java:12: error: package org.jibx.runtime does not exist
import org.jibx.runtime.JiBXException;
^
example25\Test.java:25: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
^
symbol: class IBindingFactory
location: class Test
example25\Test.java:25: error: cannot find symbol
IBindingFactory bfact = BindingDirectory.getFactory(Order.class);
^
symbol: variable BindingDirectory
location: class Test
example25\Test.java:26: error: cannot find symbol
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
^
symbol: class IUnmarshallingContext
location: class Test
example25\Test.java:40: error: cannot find symbol
IMarshallingContext mctx = bfact.createMarshallingContext();
^
symbol: class IMarshallingContext
location: class Test
example25\Test.java:52: error: cannot find symbol
} catch (JiBXException e)
^
symbol: class JiBXException
location: class Test
10 errors
All the class files used by Test are present next to it and have been properly compiled.
Test is the last file that is giving me trouble. Furthermore some of the classes used in test are present in C:\jibx\lib> as opposed to C:\jibx\tutorial> from where i am executing commands. Any suggestions on how i cld resolve this issue without modifying my previously generated class files would be appreciated.

add the directory C:\jibx\lib to your classpath e.g.
SET CLASSPATH=%CLASSPATH%;C:\jibx\lib;.
and then do a javac

As there are some import errors set the class path properly as Satya said, And the your current class in some directory you should compile it with -d attribute of javac
As shown below
javac -d . YourfileName.java

Related

Error: package android.util does not exist

I am trying to compile my java code, so I first convert it to .class, then to .dex and finally to smali, this has always worked, except for now as I am using the method Log.e() instead of System.out.println() to log some errors; I am unable to convert the .java file to .class.
This is the command I launch to get the .class file:
$ javac helloworld.java
Even though I've imported the library import android.util.Log;
I get the following Error:
sources/com/canal/android/external/CplusJni.java:9: error: package android.util does not exist
import android.util.Log;
^
sources/com/canal/android/external/CplusJni.java:25: error: cannot find symbol
Log.e("-----------------------------------------------------------------------------");
^
symbol: variable Log
location: class CplusJni
sources/com/canal/android/external/CplusJni.java:26: error: cannot find symbol
Log.e("cplusPKCS12Cert: ",cplusPKCS12Cert);
^
symbol: variable Log
location: class CplusJni
sources/com/canal/android/external/CplusJni.java:27: error: cannot find symbol
Log.e("-----------------------------------------------------------------------------");
^
symbol: variable Log
location: class CplusJni
sources/com/canal/android/external/CplusJni.java:35: error: cannot find symbol
Log.e("-----------------------------------------------------------------------------");
^
symbol: variable Log
location: class CplusJni
sources/com/canal/android/external/CplusJni.java:36: error: cannot find symbol
Log.e("sSLSocketFactory: ",sSLSocketFactory);
^
symbol: variable Log
location: class CplusJni
sources/com/canal/android/external/CplusJni.java:37: error: cannot find symbol
Log.e("-----------------------------------------------------------------------------");
^
symbol: variable Log
location: class CplusJni
7 errors
Here is my code:
package com.canal.android.external;
import java.io.ByteArrayInputStream;
import java.security.KeyStore;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import android.util.Log;`
public class CplusJni {
public static native byte[] getCplusPKCS12Cert();
public static native byte[] getCplusPKCS12Pass();
static {
System.loadLibrary("cplusnative");
}
public static SSLSocketFactory a() {
SSLSocketFactory sSLSocketFactory = null;
try {
SSLContext instance = SSLContext.getInstance("TLS");
byte[] cplusPKCS12Cert = getCplusPKCS12Cert();
Log.e("-----------------------------------------------------------------------------");
Log.e("cplusPKCS12Cert: ",cplusPKCS12Cert);
Log.e("-----------------------------------------------------------------------------");
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(cplusPKCS12Cert);
KeyStore instance2 = KeyStore.getInstance("PKCS12");
byteArrayInputStream.close();
KeyManagerFactory instance3 = KeyManagerFactory.getInstance("X509");
instance.init(instance3.getKeyManagers(), null, null);
HttpsURLConnection.setDefaultSSLSocketFactory(instance.getSocketFactory());
sSLSocketFactory = instance.getSocketFactory();
Log.e("-----------------------------------------------------------------------------");
Log.e("sSLSocketFactory: ",sSLSocketFactory);
Log.e("-----------------------------------------------------------------------------");
return sSLSocketFactory;
} catch (Exception unused) {
return sSLSocketFactory;
}
}
}
I would appreciate some help with this!
try to solve it this way
Step by step:
1- Open Auto Import settings
2- Switch off Optimize imports on the fly
3- Remove class in Exclude list

How to compile an edited java file into a class class file that's a part of a package [Related to Minecraft]

So I have am trying to edit a class file that is in a .jar file (the .jar file has a few other classes but I am only trying to edit this one). I used the source .java for this specific class and I am having trouble compiling it into a class, because the compiler calls errors because it is calling things from the package.
Does anybody know what the problem is?
Alternatively, it would be really helpful if someone knew of a program that would allow me to directly edit the code of a .class file in a .jar file without all the decompiling and recompiling.
Extra information
The .jar file is a Minecraft mod I'm whipping up for a friend.
Code of original .class (which works):
package pw.cinque.cpsmod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent$ClientTickEvent;
import net.minecraftforge.client.event.MouseEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraftforge.client.event.MouseEvent;
import pw.cinque.cpsmod.CPSMod;
public class ClickListener
{
public ClickListener() {}
private boolean hasClickedThisTick = false;
#cpw.mods.fml.common.eventhandler.SubscribeEvent
public void onMouse(MouseEvent event) {
if (button != 0) {
return;
}
if ((CPSMod.preventDoubleclicks) && (buttonstate) && (hasClickedThisTick)) {
event.setCanceled(true);
return;
}
if (buttonstate) {
hasClickedThisTick = true;
CPSMod.addClick();
}
}
#cpw.mods.fml.common.eventhandler.SubscribeEvent
public void onClientTick(cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent event) {
hasClickedThisTick = false;
}
}
Code of file I edited:
package pw.cinque.cpsmod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent$ClientTickEvent;
import net.minecraftforge.client.event.MouseEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import net.minecraftforge.client.event.MouseEvent;
import pw.cinque.cpsmod.CPSMod;
public class ClickListener {
private boolean hasClickedThisTick = false;
int newVar = 0;
#SubscribeEvent
public void onMouse(MouseEvent event) {
if (event.button != 0) {
return;
}
if (CPSMod.preventDoubleclicks && event.buttonstate && this.hasClickedThisTick) {
event.setCanceled(true);
return;
}
if (event.buttonstate)
{
this.hasClickedThisTick = true;
CPSMod.addClick();
newVar = CPSMod.getClicks();
if(newVar > 5)
{
CPSMod.addClick();
}
}
}
#SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
this.hasClickedThisTick = false;
}
}
These are the error messages I get when I try to compile it.
ClickListener.java:2: error: package cpw.mods.fml.common.eventhandler does not exist
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
^
ClickListener.java:3: error: package cpw.mods.fml.common.gameevent does not exist
import cpw.mods.fml.common.gameevent.TickEvent;
^
ClickListener.java:4: error: package cpw.mods.fml.common.gameevent does not exist
import cpw.mods.fml.common.gameevent.TickEvent$ClientTickEvent;
^
ClickListener.java:5: error: package net.minecraftforge.client.event does not exist
import net.minecraftforge.client.event.MouseEvent;
^
ClickListener.java:7: error: package cpw.mods.fml.common.eventhandler does not exist
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
^
ClickListener.java:8: error: package cpw.mods.fml.common.gameevent does not exist
import cpw.mods.fml.common.gameevent.TickEvent;
^
ClickListener.java:9: error: package net.minecraftforge.client.event does not exist
import net.minecraftforge.client.event.MouseEvent;
^
ClickListener.java:10: error: cannot find symbol
import pw.cinque.cpsmod.CPSMod;
^
symbol: class CPSMod
location: package pw.cinque.cpsmod
ClickListener.java:17: error: cannot find symbol
public void onMouse(MouseEvent event) {
^
symbol: class MouseEvent
location: class ClickListener
ClickListener.java:40: error: package TickEvent does not exist
public void onClientTick(TickEvent.ClientTickEvent event) {
^
ClickListener.java:16: error: cannot find symbol
#SubscribeEvent
^
symbol: class SubscribeEvent
location: class ClickListener
ClickListener.java:39: error: cannot find symbol
#SubscribeEvent
^
symbol: class SubscribeEvent
location: class ClickListener
ClickListener.java:21: error: cannot find symbol
if (CPSMod.preventDoubleclicks && event.buttonstate && this.hasClickedThisTick) {
^
symbol: variable CPSMod
location: class ClickListener
ClickListener.java:25: error: illegal start of type
if (event.buttonstate) {
^
ClickListener.java:27: error: cannot find symbol
CPSMod.addClick();
^
symbol: variable CPSMod
location: class ClickListener
ClickListener.java:28: error: cannot find symbol
gay = CPSMod.getClicks();
^
symbol: variable CPSMod
location: class ClickListener
ClickListener.java:33: error: cannot find symbol
CPSMod.addClick();
^
symbol: variable CPSMod
location: class ClickListener
17 errors
You need to compile that class with all its dependencies, otherwise it will not work. Probably you should get all the files from that .jar, make the modifications you want and then compile and compress it again.

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.

Error importing a static class from default package in java [duplicate]

This question already has answers here:
What does a "Cannot find symbol" or "Cannot resolve symbol" error mean?
(18 answers)
Closed 6 years ago.
I am trying to cut short the System.out.println() by defining a static method inside Util.java. I would like to make use of Util.print() further shortened into print(). So I have did a static import.
Util.java is present under the same directory as ListOfNumbers.java. When I try to access writeList() from a tester class I get the below error:
import java.io.*;
import java.util.List;
import java.util.ArrayList;
import static Util;
public class ListOfNumbers {
...
...
public void writeList() {
// The FileWriter constructor throws IOException, which must be caught.
PrintWriter out = null;
try {
print("Entered try statement...");
...
} catch (IOException | IndexOutOfBoundsException e){
print("Exception thrown: \n" + e.getMessage());
...
}
}
}
Error:
>> javac Tester.java && java Tester
.\ListOfNumbers.java:4: error: '.' expected
import static Util;
^
.\ListOfNumbers.java:4: error: ';' expected
import static Util;
^
.\ListOfNumbers.java:4: error: cannot find symbol
import static Util;
^
symbol: class Util
.\ListOfNumbers.java:4: error: static import only from classes and interfaces
import static Util;
^
.\ListOfNumbers.java:24: error: cannot find symbol
print("Entered try statement...");
^
symbol: method print(String)
location: class ListOfNumbers
.\ListOfNumbers.java:34: error: cannot find symbol
print("Exception thrown: \n" + e.getMessage());
^
symbol: method print(String)
location: class ListOfNumbers
6 errors
You should import the method name
import static Util.print;
If you want to import all static methods from Util:
import static Util.*;
The below answer helped me to overcome the problem! Guess this must be a bug.
Java static member from default package cannot be imported!

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