PC Review


Reply
Thread Tools Rate Thread

converting from Java

 
 
cs_hart@yahoo.com
Guest
Posts: n/a
 
      19th Jan 2005
I have an application in Java that I would like to port to c++ to
integrate with existing c++ app. Is anyone aware of any tools to help?

I found microsft has a java->c# convert, but the java app has class
that do multiple subclassing and this doesn't seem to work in C#.
Is there any to port C# to c++?
thanks...charlie

 
Reply With Quote
 
 
 
 
Alessandro Angeli [MVP::DigitalMedia]
Guest
Posts: n/a
 
      19th Jan 2005
(E-Mail Removed) wrote:

> I have an application in Java that I would like to port
> to c++ to integrate with existing c++ app. Is anyone
> aware of any tools to help?


Do you mean managed C++? You can not port Java to native C++
because most Java features require a VM to be supported.
Even if you mean mC++, there is no way to automatically port
Java to C++ AFAIK because it is far from easy to express the
higher level constructs of the Java language and API in C++.

What kind of integration do you need? Maybe you can use JNI
with standard Java or the .NET InterOp services if you port
Java to J# (which is a breeze as long as your Java code
conforms to Java 1.1).

> I found microsft has a java->c# convert, but the java app
> has class that do multiple subclassing and this doesn't
> seem to work in C#.


C# is a superset of the Java language (but for some of the
features introduced in Java5), so you can always port Java
source code to C# (this is not always true for Java API
calls).

> Is there any to port C# to c++?


Not that I'm aware of. Even if everything that can be
expressed in C# can also be expressed in C++, some higher
level constructs can not be preserved, just like with Java.


--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      19th Jan 2005
Alessandro Angeli [MVP:igitalMedia] wrote:
>
> Do you mean managed C++? You can not port Java to native C++
> because most Java features require a VM to be supported.
> Even if you mean mC++, there is no way to automatically port
> Java to C++ AFAIK because it is far from easy to express the
> higher level constructs of the Java language and API in C++.



I do not know C# and Java, but may you provide an example of a Java
construct that cannot be expressed in C++?




--
Ioannis Vranos
 
Reply With Quote
 
Tom Widmer
Guest
Posts: n/a
 
      19th Jan 2005
Ioannis Vranos wrote:
> Alessandro Angeli [MVP:igitalMedia] wrote:
>
>>
>> Do you mean managed C++? You can not port Java to native C++
>> because most Java features require a VM to be supported.
>> Even if you mean mC++, there is no way to automatically port
>> Java to C++ AFAIK because it is far from easy to express the
>> higher level constructs of the Java language and API in C++.

>
>
>
> I do not know C# and Java, but may you provide an example of a Java
> construct that cannot be expressed in C++?


Anonymous inner classes can't easily be expressed.

Tom
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      19th Jan 2005
Tom Widmer wrote:

> Anonymous inner classes can't easily be expressed.



Do you mean something like this?


class A
{
class
{
int x;
}y;
};


int main()
{
A a;
}




--
Ioannis Vranos
 
Reply With Quote
 
Gabest
Guest
Posts: n/a
 
      19th Jan 2005
As I recall Java allows classes to be delcared inside functions, not just
inside other classes. It was a pretty nice feature.


 
Reply With Quote
 
Alessandro Angeli [MVP::DigitalMedia]
Guest
Posts: n/a
 
      19th Jan 2005
Ioannis Vranos wrote:

> Do you mean something like this?
>
>
> class A
> {
> class
> {
> int x;
> }y;
> };
>
>
> int main()
> {
> A a;
> }


No, that's just a nested class. He meant something like
this:

public interface I
{
public int f();
};

....
I i = new I() {
public int f() { return 2; }
};
....

In this case, the Java compiler creates an implementing
class that has no name and can not be referenced but by its
instances.

Also, the Java language has a >>> operator and a finally
clause that C++ is missing (but the >>> operator is easy to
implement as an expression).

Anyway, I wrote it is not easy to express some constructs
and not that it is impossible. After all, everything can be
expressed in ASM :-)



--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net


 
Reply With Quote
 
Alessandro Angeli [MVP::DigitalMedia]
Guest
Posts: n/a
 
      19th Jan 2005
Gabest wrote:

> As I recall Java allows classes to be delcared inside
> functions, not just inside other classes. It was a pretty
> nice feature.


Hi there, a familiar face :-) I think you are referring to
local classes, which are similar to anoymous classes but not
quite the same. Local class are classes declared inside
methods while anonynous class are declared "inline".


--

// Alessandro Angeli
// MVP :: Digital Media
// a dot angeli at psynet dot net



 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      19th Jan 2005
Gabest wrote:

> As I recall Java allows classes to be delcared inside functions, not just
> inside other classes. It was a pretty nice feature.



Do you mean something like this?


class A
{
public:

void somemethod()
{
class
{
public:
int x;
}y;

y.x=1;
}
};


int main()
{
A a;
}


:-)




--
Ioannis Vranos
 
Reply With Quote
 
Jeff F
Guest
Posts: n/a
 
      19th Jan 2005
Gabest wrote:
> As I recall Java allows classes to be delcared inside functions, not
> just inside other classes. It was a pretty nice feature.


void function_with_embedded_class()
{
class embedded_class
{
int member;
public:

embedded_class():member(123){}
}

embedded_class an_embedded_class_instance;
}

Works for me, even in vc6.

Jeff


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tips of Converting from Java to C# & .NET swebb99 Microsoft C# .NET 4 14th Feb 2008 11:29 AM
Converting Java to C# Jay Microsoft C# .NET 10 7th Apr 2007 07:05 AM
Converting Java Applet to C# farseer Microsoft C# .NET 5 28th Dec 2006 10:44 PM
Converting a simple .net app to java app??? Scott Microsoft VB .NET 5 5th Jul 2005 12:05 PM
Converting from java beans to c# =?Utf-8?B?U3RlcGhlbiBILg==?= Microsoft ASP .NET 9 21st Jun 2005 03:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:50 AM.