Trying to implement the Java SDK, following the tutorial here: https://blogs.msdn.microsoft.com/bharry/2011/05/16/announcing-a-java-sdk-for-tfs/
I have the libraries imported, but getting a compilation error
TFSTeamProjectCollection tpc =
new TFSTeamProjectCollection(BASEURL);
BASEURL is a string I defined earlier in the code.
The error is: The constructor TFSTeamProjectCollection(String) is undefined
Does anyone know how to resolve this issue?
Well, studying the C# side of things ( see here ) I can't find a constructor that would only take a String argument.
There is only a single argument constructor taking a Uri.
In other words: the fact that you your string contains a Url; and that you named it a BASEURL doesn't magically turn it from a String into a URL or URI class object.
Guessing: the ctor wants an argument of type java.net.URL which you could probably create with something like new URL(BASEURL); instead of just passing BASEURL to that constructor.
The thing is: in order to actually understand which constructors that Team Foundation class has; one would need access to the corresponding SDK from Microsoft - which you probably downloaded and and have in place. So, the only thing that you need to do ... read the javadocs!
Related
I am using Jacob to call VBA COM interfaces in software.
I need to call a Sub that has an output parameter, that is not of canonical type (int, String, etc.) but of some dedicated interface declared in .tlb that are brought with this software.
Here is the
Sub GetMaterialOnBody (Body iBody, Material oMaterial)
So I tried many declarations and initializations for the output parameter material in the call, I get various errors and cannot seem to find the proper way to do.
Variant material = new Variant (null, false);
Dispatch.invoke(materialManager.getDispatch(), "GetMaterialOnBody", Dispatch.Method, new Object[] {hybridBody, material}, new int[1]);
but got
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: GetMaterialOnBody
Description: Type mismatch.
Then I tried to call .getDispatch() on material
Variant material = new Variant (null, false);
Dispatch.invoke(materialManager.getDispatch(), "GetMaterialOnBody", Dispatch.Method, new Object[] {hybridBody, material.getDispatch()}, new int[1]);
but got
java.lang.IllegalStateException: getDispatch() only legal on Variants of type VariantDispatch, not 0
So I tried
Variant material = new Variant (null, false);
material.putNothing();
Dispatch.invoke(materialManager.getDispatch(), "GetMaterialOnBody", Dispatch.Method, new Object[] {hybridBody, material.getDispatch()}, new int[1]);
but got
com.jacob.com.ComFailException: putObject failed
at com.jacob.com.Variant.putVariantDispatch(Native Method) ~[jacob-1.14.3.jar:na]
at com.jacob.com.Variant.putDispatch(Variant.java:1341) ~[jacob-1.14.3.jar:na]
I tried different solutions, including using Ref, etc.
I am a bit lost on how exactly we have to initialize a variant/dispatch to pass as an output parameter in a Sub.
Does anyone have any clue on how to do that? The closes resources I found were handling String/Integer and not object.
This old question might be related (but obviously no answer): https://community.oracle.com/tech/developers/discussion/1548970/jacob-out-parameters-refs-in-jni
I have open a question on the jacob github
https://github.com/freemansoft/jacob-project/issues/23
Also I emailed the owner of the project on github and he said the project was dormant for some time already. As all the code is available I will take the time to compile and debug the native (C++) side in order to debug my case. I will update that question then.
if that is output parameter, shouldn't it be 'ByRef' ?
Sub GetMaterialOnBody (Body iBody, ByRef Material oMaterial)
In your case probably GetMaterialOnBody sub is expected to fill in internals of oMaterial object, not to set reference to it? Then just create an empty Material object and pass to the sub
I'm trying to use the EWS Java library (link) with LispWorks 7.1.2 Win32's Java interface. I am somewhat familiar with basic Java concepts but have no experience with the Java language. This is the code I am trying to mimic:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
So I figured I would create an ExchangeVersion object (which is an enum), set it to the value "Exchange2010_SP2", and pass it to another create-java-object expression for the ExchangeService object.
This was my first step:
(create-java-object "microsoft.exchange.webservices.data.core.ExchangeService"
"microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion.Exchange2010_SP2")
However, I get the following error message: constructor of microsoft/exchange/webservices/data/core/ExchangeService first arguments is wrong type, wanted microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion got "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion.Exchange2010_SP2"
OK, so then I tried this:
(create-java-object "microsoft.exchange.webservices.data.core.ExchangeService"
"microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion")
which gave me the error: constructor of microsoft/exchange/webservices/data/core/ExchangeService first arguments is wrong type, wanted microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion got "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion". Which doesn't make much sense to me. So finally I tried to create a standalone ExchangeVersion object:
(create-java-object "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion")
which led to this error message: CREATE-JAVA-OBJECT: : Failed to find constructors for class "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion".
I wonder if anyone have suggestions on what am I doing wrong?
Many Thanks!
I have a Java class that mainly contains strings. It does not have a layout as it is neither a Fragment nor an Activity. It is more used as an auxilliary class. I would like to assign the String values in the class by using the Resource strings as I would like to automatically translate the Strings. Howvever, I can't access the string resources from Java. I use the following code:
static String more = getString(R.string.more);
And in the XML file I have the ressource:
<string name="more">More</string>
I get the error message
Cannot resolve method 'getString'
I also tried static String more = getContext().getString(R.string.more);
but I got the error message:
Cannot resolve method 'getContext'
Would anyone mind helping me on that? I'd appreciate every comment.
Update: I tried to use the answer from "MikaelM"
Resources.getSystem().getString(R.string.more)
However, I get an "exception in initializer error" and when I use the initial String again, I do not get this error. So I still can't get the String from the ressource. DO you have an idea what I can do? I'd appreciate every further comment.
So the error is caused by "Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f120038"
The strange thing is that the resource in fact exists (I checked this several times).
getString(R.string...
is not the same as
Resources.getSystem().getString(android.R.string...
Only the second variant you can use in the static context. Alas, you can get this way only system resources.
If you need to get your own resources, no one-line solution exists. Use https://stackoverflow.com/a/4391811/715269 solution of #Cristian. And notice: it is a very good solution, even more, it is the solution meant to be used by the creators of Android.
You should be able to get your string with:
Resources.getSystem().getString(R.string.more)
See more here, getString Outside of a Context or Activity
I've build a method which takes strings as input parameter. In my index.jsp page, I retrieve a GET-variable from the URL using request.getParameter(). Now, I want to call the aforementioned method on this string, but I get a compiler error saying:
The method <method name>(String) is undefined for the type __2F_<webapp name>_2F_src_2F_main_2F_webapp_2F_index_2E_jsp".
Does anyone know why I get this error and how I can get rid of it. Any help is greatly appreciated!
My code is rather lengthy, but I think this is relevant code:
categorie = request.getParameter("categorie");
if (categorie.equals("")) {
categorie = "Category;";
}
ArrayList<String> categorieen = queryCategories(categorie);
You are calling ArrayList<String> categorieen = queryCategories(categorie); and you did not define queryCategories method. Since the JSP page is compiled into a big servlet class, it tries to locate queryCategories method as member of that class and it could not find it.
Very little information. Where is your app deployed? From what I gather, it seems you either haven't restarted the deployed app or have not replaced the changed class file and haven't set some sort of "development mode" on wherein you don't require a restart for a Jsp modification.
Just replace the .jsp and JSP_NAME.class file.
I instantiate a COM Object, then invoke a method.
ActiveXComponent comp = new ActiveXComponent("MyDll.MyClass");
String argument1 = "test1";
String argument2 = "test2";
Variant[] arguments = { new Variant(argument1), new Variant(argument2) };
comp.invoke("myMethod", arguments)
Assuming MyDll has a method called
myMethod(String s1, String s2)
it works fine.
Now, what if I have a Method
myMethod(String s1, ReturnDeletedModeEnum enum)
with an enum defined in MyDll?
I need to pass the enum to the method somehow, but I don't know how to access it.
I tried getting the Enum as ActiveXComponent,
new ActiveXComponent("MyDll.ReturnDeletedModeEnum");
which (not surprisingly) didn't work:
com.jacob.com.ComFailException: Can't get object clsid from progid
I tried finding some more documentation about Jacob, because there seem to be Enum-specific classes, but I haven't found any explanation on how to use them.
I ran into the same uncertainty when I needed to call a method with an Enummeration parameter. I couldn't find much documentation - JACOB or otherwise.
I did stumble across a helpful post on the subject which says the values ... correspond to internally stored numbers and An enumeration in VBA is always of data type Long.
Armed with that and the MS Documentation for my particular Enumeration, I gave this a try ...
Dispatch.call(oDocuments, "Open", fileIn, ... , new Variant(1L));
And it worked!
I'm sure there's a way to get actual "Enumeration" data structures, but this was good enough for me.