|
|
|
|
|
|
|
|
|
Re: Does anyone know how to work with gcj on windows and to make an EXE [message #189450 is a reply to message #188211] |
Mon, 13 December 2004 02:14   |
Eclipse User |
|
|
|
Originally posted by: melko.gmx.at
Hallo!
It doesn't work that way. I don't know why, but I did all this that you
wrote here and it doesn't work. At first I need more different
database-driver and when I want to compile my drivers it can only compile
SQLBaseJDBC.jar the other ones doesn't go but if I compile this one and
make the exe-file as you wrote it goes but I cannot make a connection.
I hope someone can help me!! THANKS
nice greetings.
Radu Racariu wrote:
> Hi Melko,
> I'm the author of the GCJBuilder plugin and your problem has nothing to
> do with it.
> First you should take a look at how GCJ works and the differences from
> pure Java.
> To explain it simply, GCJ needs to have all the references from java
> classes already compiled as native (object) code in order to perform
> dynamic loading of a class.
> This issue is affecting you most likely, as you are using Driver manager
> to load your db specific driver dynamicly.
> A simple scenario looks like this.
> you should compile the driver jar as object code
> i.e. gcj -c mysqljdbc.jar
> this will produce a file named mysqljdbc.o which contains native code.
> then say your connection class is called connection.java, pls mind the
> commented lines before "com.mysql.jdbc.Driver dummyRef;"
> it should look like this:
> [start - connection.java ]
> package com.stardeveloper.example;
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
> public class connection{
> /* this line will force gcj linker to include
> native code from drivers object code by simply referencing
> drivers class.
> */
> com.mysql.jdbc.Driver dummyRef;
> public static void main(String args[]) {
> Connection con = null;
> try {
> // mind the quoted driver name, the compiler doens't know about
> // that class and we have to give it hints as seen above
> Class.forName("com.mysql.jdbc.Driver").newInstance();
> con = DriverManager.getConnection("jdbc:mysql:///test",
> "root", "secret");
> if(!con.isClosed())
> System.out.println("Successfully connected to " +
> "MySQL server using TCP/IP...");
> } catch(Exception e) {
> System.err.println("Exception: " + e.getMessage());
> } finally {
> try {
> if(con != null)
> con.close();
> } catch(SQLException e) {}
> }
> }
> }
> [ end - connection.java]
> you should compile it with
> gcj -c --classpath=mysqljdbc.jar connection.java
> then last step is to link both '.o' files and create an exe file:
> gcj --main=connection connection.o mysqljdbc.o -o mysql.exe
> now you'll have mysql.exe ready for run
> thats it.
> GCJBuilder will simplify your work but you must understand the basics first.
> take care,
> Radu Racariu
> melko wrote:
>> Hallo!
>>
>> Does anyone know how to work with gcj and to make an EXE-file out of the
>> java-files! And the biggest problem is to include Database-Driver so I
>> can searxh for the Class?!
>> THANKS
>>
|
|
|
|
Re: Does anyone know how to work with gcj on windows and to make an EXE [message #189607 is a reply to message #188211] |
Tue, 14 December 2004 07:10   |
Eclipse User |
|
|
|
sorry there was an error in my example,
pls remove the package line ("package com.stardeveloper.example;") :).
regards
Radu Racariu wrote:
> Hi Melko,
>
> I'm the author of the GCJBuilder plugin and your problem has nothing to
> do with it.
> First you should take a look at how GCJ works and the differences from
> pure Java.
>
> To explain it simply, GCJ needs to have all the references from java
> classes already compiled as native (object) code in order to perform
> dynamic loading of a class.
>
> This issue is affecting you most likely, as you are using Driver manager
> to load your db specific driver dynamicly.
>
> A simple scenario looks like this.
>
> you should compile the driver jar as object code
>
> i.e. gcj -c mysqljdbc.jar
> this will produce a file named mysqljdbc.o which contains native code.
>
>
> then say your connection class is called connection.java, pls mind the
> commented lines before "com.mysql.jdbc.Driver dummyRef;"
>
> it should look like this:
>
> [start - connection.java ]
>
> package com.stardeveloper.example;
>
> import java.sql.Connection;
> import java.sql.DriverManager;
> import java.sql.SQLException;
>
> public class connection{
>
>
> /* this line will force gcj linker to include
> native code from drivers object code by simply referencing
> drivers class.
>
> */
>
> com.mysql.jdbc.Driver dummyRef;
>
>
> public static void main(String args[]) {
> Connection con = null;
>
> try {
>
> // mind the quoted driver name, the compiler doens't know about
> // that class and we have to give it hints as seen above
>
> Class.forName("com.mysql.jdbc.Driver").newInstance();
>
>
> con = DriverManager.getConnection("jdbc:mysql:///test",
> "root", "secret");
>
> if(!con.isClosed())
> System.out.println("Successfully connected to " +
> "MySQL server using TCP/IP...");
>
> } catch(Exception e) {
> System.err.println("Exception: " + e.getMessage());
> } finally {
> try {
> if(con != null)
> con.close();
> } catch(SQLException e) {}
> }
> }
> }
>
> [ end - connection.java]
>
> you should compile it with
>
> gcj -c --classpath=mysqljdbc.jar connection.java
>
> then last step is to link both '.o' files and create an exe file:
>
> gcj --main=connection connection.o mysqljdbc.o -o mysql.exe
>
> now you'll have mysql.exe ready for run
>
> thats it.
>
> GCJBuilder will simplify your work but you must understand the basics
> first.
>
> take care,
> Radu Racariu
>
>
>
> melko wrote:
>
>> Hallo!
>>
>> Does anyone know how to work with gcj and to make an EXE-file out of
>> the java-files! And the biggest problem is to include Database-Driver
>> so I can searxh for the Class?!
>> THANKS
>>
|
|
|
Re: Does anyone know how to work with gcj on windows and to make an EXE [message #189702 is a reply to message #189607] |
Wed, 15 December 2004 03:59   |
Eclipse User |
|
|
|
Originally posted by: melko.gmx.at
Thank you for your answer but the problem is somewhere else! I have no
mysql driver and I needn't. I need all other drivers, like
SQLBaseJDBC.jar, ojdbc14.jar, jt400.jar and so on but when I want to make
an object out of them only the SQLBaseJDBC.jar goes so I made my script on
this driver based. Now the connection.java file looks like this:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class connection{
jdbc.gupta.sqlbase.SqlbaseDriver dummyRef;
public static void main(String args[]) {
Connection con = null;
try {
Class.forName("jdbc.gupta.sqlbase.SqlbaseDriver").newInstance();
con =
DriverManager.getConnection("jdbc:sqlbase://192.168.192.252:2160/database","secret",
"secret");
if(!con.isClosed())
System.out.println("Successfully connected to SQLBase");
} catch(Exception e) {
System.err.println("Exception: " + e.getMessage());
} finally {
try {
if(con != null)
con.close();
} catch(SQLException e) {}
}
}
}
and the *.bat file looks like this:
@echo off
SETLOCAL
echo make SQLBase-Object...
gcj -c SQLBaseJDBC.jar
echo make connection-Object...
gcj -c --classpath=SQLBaseJDBC.jar connection.java
echo make *.exe...
gcj --main=connection SQLBaseJDBC.o connection.o -o test.exe
echo.
echo End!
pause
And i get this test.exe without any errors but I cannot make any
connection!!
I get the error-message: "No driver found for jdbc:sqbase://...."
I must make an exe-file because I work on a program that should be similar
to the SQLTalk, if you know what it is, it's a
database-communication-program and so it should be easy transportable. It
also contains SWT-Widgets but this problem I have solved, so I get a
window and all but no connection!!!
Thank you for your help.
nice greatings from very cold austria
Radu Racariu wrote:
> sorry there was an error in my example,
> pls remove the package line ("package com.stardeveloper.example;") :).
> regards
|
|
|
|
Re: Does anyone know how to work with gcj on windows and to make an EXE [message #189923 is a reply to message #189909] |
Fri, 17 December 2004 06:52  |
Eclipse User |
|
|
|
Originally posted by: hcs33.egon.gyaloglo.hu
Hi,
I don't think that messages was deleted on the server. If you use Outlook
Express as your news reader, look at Tools->Options->Maintenance and see
whether there is a setting "Delete new messages..." is checked.
HTH,
Regards,
Csaba
"melko" <melko@gmx.at> wrote in message news:cpue0q$it4$1@www.eclipse.org...
> IMPORTANT!!
>
> Who has deleted the other posts that where here under this point?!? There
> were min. 10 posts?! Where are they?!
> Thank you for information!
>
> nice greetings!
>
>
> melko wrote:
>
> > Hallo!
>
> > Does anyone know how to work with gcj and to make an EXE-file out of the
> > java-files! And the biggest problem is to include Database-Driver so I
can
> > searxh for the Class?!
>
> > THANKS
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.05286 seconds