11

At the head of my class (I am taking over a project from someone else), I have the following:

using Java.Util;
using Object = Java.Lang.Object;
using Void = Java.Lang.Void;

Void, is showing in red, with a "Cannot resolve symbol 'Void'" and cannot see what I may be missing.

I have checked the PC where this came from (and the application does build on that one) and have installed the same (yes, I saw, newer, but specifically installed the "same" items) Java items:

  • Java 7 Update 45
  • Java 6 Update 31
  • Java SE Development Kit 6 Update 31

This hasn't made any change.

I have checked the 'References' branch of the project and everything is showing the same (in fact, I cannot see a specific reference to Java anywhere)

Any help would be appreciated to sort this.

Please understand that I am not looking to change the code; just to get the code (as is) to compile without error.

[Update]

When I type out Java.Lang. the intellisense does not show Void in the dropdown list

[Further Update]

This project is tied to the development for a tablet; for which I hadn't installed some of the development software - installing these has resolved the issue and I can only assume that the Java namespace is buried within the software. Whilst there's no specific answer in the responses, most of the comments have certainly helped to steer me in the right direction.

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Sean
  • 862
  • 8
  • 28

4 Answers4

2

There are several possible ways a C# project consuming Java bits,

Based on the fragment you pasted I think you might be opening a Xamarin.Android project in Visual Studio, as the using clauses match,

http://androidapi.xamarin.com/?link=N%3aJava.Util

http://androidapi.xamarin.com/?link=T%3aJava.Lang.Void

http://androidapi.xamarin.com/?link=T%3aJava.Lang.Object

Thus, you need to have Xamarin.Android completely installed on this machine. What you have (JRE and JDK) is obviously not enough.

dot42 does not have Java.Lang.Void and Java.Lang.Object, http://docs.dot42.com/Reference/NS.Java.Lang

Lex Li
  • 60,503
  • 9
  • 116
  • 147
0

I think these links would be helpful for you.

What is the difference between java.lang.Void and void? http://docs.oracle.com/javase/7/docs/api/java/lang/class-use/Void.html

Community
  • 1
  • 1
  • This would imply a change to code; as commented this was not about correcting code, it was about getting an application to compile (which it was doing on another PC) – Sean Jan 14 '14 at 14:41
0

FAIL:

using Java.Lang.Void;
import Java.Lang.Void;

SUCCESS:

import java.lang.Void;
TheRed__
  • 164
  • 11
-2

You have to use import instead of using.

import Java.Util.*;
Object blah = new Java.Lang.Object;

If you want to create an object that is null, do this:

Object obj = new Object();

If you want to add data set it equal to data such as a number.

obj = 7;
poy
  • 10,063
  • 9
  • 49
  • 74
  • As discussed in the comments, this isn't Java. – Paul Bellora Jan 09 '14 at 19:37
  • But no one answered it as a response. – CrazyJohnny Jan 09 '14 at 19:39
  • Yes, because neither your answer nor "it's not Java" is a solution for this question. It's about getting that C# code to compile, with those using directives as they are. – grexter89 Jan 10 '14 at 12:43
  • Seemed to me like he was trying to program in java. Everything in his post relates to java. If you think he was trying to program in C# then you are wrong. – CrazyJohnny Jan 10 '14 at 19:10
  • I can confirm (as per the [Further Updates] in my original post; that this was resolved by installing some missing components. For clarification on the commnets: +grexter89 was correct that it was about getting C# code to compile (without making code changes) and +CrazyJohnny it is not code written in Java. – Sean Jan 14 '14 at 14:40
  • Sounds like you solved your problem!? You should post it as an answer to this question, so that other people with a similar problem can quickly get help here. – grexter89 Jan 15 '14 at 13:44