all groups > vj# > december 2003 >
You're in the

vj#

group:

Quickest way to convert J Sharp to standard Java for compilation?


Quickest way to convert J Sharp to standard Java for compilation? Horus Alkebulan
12/17/2003 1:16:25 PM
vj#: I'm a first year computer science student, but a long time Visual Studio
..NET user. I would love to be able to write my Java code with VS.NET
2003 but my projects must be submitted as SDK1.4 .java files.

What's the easiest way to convert my .jsl files to standard .java files
so I can compile with JavaC.exe and run with Java.exe?

I tried writing a simple console app in VS.NET using J Sharp and just
changing the extensions to .java but I get errors when running "JAVA
ClassName." It seems to compile okay as all the .class files are generated.

TIA!

Horus

Error and code is below...

====== ERROR =========

C:\Documents and Settings\xxxxx\My Documents\Visual Studio
Projects\poly>java Class1

Exception in thread "main" java.lang.NoClassDefFoundError: Class1 (wrong
name: poly/Class1)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

====== CODE =========

package poly;

public class Class1
{
public Class1()
{
}

/** @attribute System.STAThread() */
public static void main(String[] args)
{

System.out.println("Ready.");

System.out.println("Variable:Class, Object:Class");
poly.ModelXP100 xp1 = new ModelXP100();
xp1.processorSpeed();
xp1.floppyDrive();

System.out.println("Variable:Interface, Object:Class");
poly.Computer xp1i = new ModelXP100();
xp1i.processorSpeed();
}
}
Re: Quickest way to convert J Sharp to standard Java for compilation? Bruno Jouhier [MVP]
12/17/2003 8:56:07 PM
Are you sure that your CLASSPATH is set correctly when you are trying to
execute the version compiled with the java compiler.

As long as your source does not use any of the .NET extensions (conditional
compile for ex), you should be able to recompile it with JavaC.exe and the
result should run.Your sample seems to indicate that you are ok.

You don't even have to rename the java source in between. You can rename
them inside Visual J# because VJ# accepts both .jsl and .java for Java
source files (otherwise it would not be compatible with VJ++).

Bruno.

"Horus Alkebulan" <replytogroup@nospam.com> a écrit dans le message de
news:umKJjnMxDHA.2304@TK2MSFTNGP12.phx.gbl...
[quoted text, click to view]

Re: Quickest way to convert J Sharp to standard Java for compilation? rlacas NO[at]SPAM online.microsoft.com
12/18/2003 1:44:02 AM
Visual J# also does not care when your source does not have the same name
as the public class, or whether or not your package structure matches
directory structure.

You can also have more than one public class in a single source file in J#.

Regards,
-Bob

[quoted text, click to view]

Bob LaCasse
Microsoft Developer Support - Visual J#.NET

This posting is provided AS IS with no warranties, and confers no rights.
AddThis Social Bookmark Button