Google analytics posted on their blog about an example Java program to extract data and output to a CSV using the analytics api, im trying to compile this program to run it in eclipse but running into problems
http://code.google.com/p/ga-api-java-samples/source/browse/trunk/src/v2/DataOverTime/src/example/MainDemo.java
i have changed out the variables in here to my own:
// User configurations.
private static final String USERNAME = "INSERT_YOUR_GOOGLE_ACCOUNT_LOGIN";
private static final String PASSWORD = "INSERT_YOUR_GOOGLE_ACCOUNT_PASSWORD";
private static final String TABLE_ID = "INSERT_YOUR_TABLE_ID";
i'm unsure on the next step, when i try to run the program i get this error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at MainDemo.main(main.java:51)
update:
ok, its says when using the google analytics API i need to reference some .jar files:
gdata-core-1.0.jar
gdata-client-meta-1.0.jar
gdata-client-1.0.jar
gdata-analytics-meta-2.0.jar
gdata-analytics-2.0.jar
google-collect-1.0-rc1.jar
jsr305.jar
i put these in but its still not working i get the following error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Results cannot be resolved to a type
The method getData(DataQuery) from the type DataOverTime refers to the missing type Results
Is your directory structure correct? It should look somewhat like the url of the example.
The file has to be './example/MainDemo.java' and compile it from '.'
I got the answer in this forum: http://code.google.com/apis/analytics/groups/exportApiGroup.html?place=topic%2Fgoogle-analytics-data-export-api%2FwpDmftjYFio%2Fdiscussion
Related
So I'm trying to write a Java program using the SAP BO SDK. When I try to create a session, using a predefined class from the SDK, I get a nullPointerException. I copied my code 1 to 1 from an SDK tutorial. Here is my code:
public class Program {
public static void main(String[] args) {
try {
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
...
}
}
}
When I run that code (I commented everything else out for testing), I get the following error:
Exception in thread "main" java.lang.NullPointerException
at com.crystaldecisions.celib.classloader.ClassLoaderHelper$2.getResourceAsStream(ClassLoaderHelper.java:102)
at com.crystaldecisions.celib.classloader.ClassLoaderHelper.getResourceAsStream(ClassLoaderHelper.java:149)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.initializeSystemProperties(SessionMgr.java:258)
at com.crystaldecisions.sdk.framework.internal.SessionMgr.<init>(SessionMgr.java:253)
at com.crystaldecisions.sdk.framework.internal.CEFactory.makeSessionMgr(CEFactory.java:94)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr_aroundBody0(CrystalEnterprise.java:121)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr_aroundBody1$advice(CrystalEnterprise.java:512)
at com.crystaldecisions.sdk.framework.CrystalEnterprise.getSessionMgr(CrystalEnterprise.java:1)
at myprogram.main(Program.java:18) <-- Line 4 in my code example above
Does this mean that there is an error in the libraries provided by the SDK? Or that I somehow imported those incorrectly? Is it possible to get any more information from this error code?
Thank you for any help or guidance you can provide.
EDIT: The tutorial used: http://bukhantsov.org/2011/08/getting-started-with-businessobjects-java-sdk/
The issue was that I was referencing JAR files directly from my Program Files. Copying the files to a local folder in my workspace, and referencing them from there fixed the problem.
I have checked out the SWI-Prolog JPL library, and I am trying to add some functionality. Right now, I am just trying to get the tests to work in the TestJUnit test. However, I am getting the following error:
SWI-Prolog: [FATAL ERROR:
Could not open resource database "../../src/swipl.prc": No error]
I have looked at the code, and I know that path is coming from this declaration:
public static final String startup =
(System.getenv("SWIPL_BOOT_FILE") == null ? "../../src/swipl.prc" :
System.getenv("SWIPL_BOOT_FILE"));
It is looking for a an environment variable %SWIPL_BOOT_FILE%, so I could see how this might fix the problem. However, I don't know which file I should add as the boot file.
I have tried the swipl-win.exe, but that doesn't work.
Any ideas?
I'm trying to load a Python class by embedding Jython in my Java application.
The code I have so far is
String pythonRoot = Main.class.getResource("/python").getPath();
PySystemState state = new PySystemState();
PyObject importer = state.getBuiltins().__getitem__(Py.newString("__import__"));
PyObject sysModule = importer.__call__(Py.newString("sys"));
final PyString pythonPath = Py.newString(pythonRoot);
PyList path = (PyList) sysModule.__getattr__("path");
path.add(pythonPath);
PyModule module = (PyModule) importer.__call__(Py.newString("building.blah.again.blah2.Test"));
PyObject klass = module.__getattr__(Py.newString("Address"));
AddressInterface ai = (AddressInterface) klass.__call__().__tojava__(AddressInterface.class);
The class I'm trying to access can be found in
/python/building/blah/again/blah2/Test.py
And the name of the class is
Address
However, this gives me the exception
Exception in thread "main" ImportError: No module named blah2
If I place some file in the directory above, like so
/python/building/blah/again/Test.py
This gives me the exception
Exception in thread "main" ImportError: No module named again
It's as if he is actively refusing to recognize directories that contains files. What can be the problem here and how might I proceed to get around this?
If you added the path of your module to the Python-path, which you did via path.add(pythonPath);, the import-command expects only the name of the module, not the full path, i.e. PyModule module = (PyModule) importer.__call__(Py.newString("Test"));
Further, you should confirm that actually the right path was added by printing the contents of the path-list. Also note that your class-declaration in Test.py must extend the Address-java-interface for toJava to work (I just mention this because this is also a common source of error).
That said, your way of using Jython appears somewhat cumbersome to me. If I were you, I would do this stuff (adding the path, doing the import) in a python-script, run it via org.python.util.PythonInterpreter (http://www.jython.org/javadoc/org/python/util/PythonInterpreter.html) and retrieve the class-PyObject via the eval or get-method.
Sub: error messages are displaying different in both eclipse and command prompt
//DataHidingDemo program
class Bank {
private static double balance = 1000;// Data Hiding
}
public class DataHidingDemo extends Bank {
public static void main(String[] args) {
System.out.println("Balance:" + balance);
}}
Case 1:
run the program from eclipse and observe below error message is displaying
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The field Bank.balance is not visible
at oops.DataHidingDemo.main(DataHidingDemo.java:10)
Case 2:
run the same program from command prompt and observe below error message is displaying
D:\Java Programs_CMD>javac DataHidingDemo.java
DataHidingDemo.java:10: error: balance has private access in Bank
System.out.println("Balance:"+balance);
^
1 error
Observe both case 1 & 2 error messages; case 2 error message has meaningful.
Q).Do we have the way to display the same error message in eclipse too? (for this do we need to change any setting in eclipse) please help on this.
Eclipse has its own Java compiler, which is thus different from javac, and thus generates different error messages. AFAIK, no, it's not possible to make Eclipse use the javac compiler. Both NetBeans and IntelliJ IDEA use javac, though, so you might want to try thise IDEs instead.
Note that the error you got from Eclipse is a message generated when you tried running code that did not compile. Don't do that. If there are compilation errors listed, then fix them all before running. The compilation errors are listed in the "Problems" view and in the "Markers" view of Eclipse.
I'm trying to call gate program from command prompt am using example from following code in this link:
http://gate.ac.uk/wiki/code-repository/src/sheffield/examples/StandAloneAnnie.java
Step 1 : I replaced StandAloneAnnie with a name "mario"
Step 2 : I added .jar and .zip files in classpath of my java program and a single document path in the argument.
Step 3 : complied it with no errors but with an exception , called the program in CMD prompt and I get following error !
Exception in thread "main" java.lang.reflect.InvocationTargetException.....
Caused by: gate.until.GateRuntimeException: Cannot guess GATE Home. Please set manually
I tried both methods
Method 1 : using Gate.setGateHome(File) using following code before Gate.init()
public static void main(String args[]) throws GateException, IOException {
// initialise the GATE library
Out.prln("Initialising GATE...");
Gate.setGateHome(new File("E:/Gate/Installation/"));
Gate.setPluginsHome(new File("E:/Gate/Installation/plugins/"));
Gate.setSiteConfigFile(new File("E:/Gate/Installation/gate.xml"));
Gate.init();
Out.prln("...GATE initialised");
Method 2: using this in cmd -Dgate.home=path/to/gate/home
java -jar mario.jar -Dgate.home=E:\Gate\Installation
More Information :
I'm using Java 1.7.45
My gate is in E:\Gate\Installation folder.
In Java i get following exception :
Exception in thread "main" java.net.MalformedURLException: unknown protocol: e
at java.net.URL.<init>(URL.java:574)
at java.net.URL.<init>(URL.java:464)
at java.net.URL.<init>(URL.java:413)
at mario.main(mario.java:98)
Am I doing something wrong in this. Please help.
Thank you.
Try Putting GATE_HOME in environment variable directing to the Gate Root directory, This might solve your problem.
Also look for the references If you have changed/renamed any variable.
My suggestion is that first you try to run with default names then change/update name as required