Onslow McCann

Greenhorn
+ Follow
since Aug 29, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Onslow McCann

YES!!!
It's working.

Thanks a lot guys, that's made my day!
10 years ago
I have ammended the PATH variable. Thanks for clearing that up Jesper.

But, sorry, I'm still not understanding it unfortunately.
I have all files in one and the same map and don't set a CLASSPATH.
I have a batch file I run to compile

DEL XFile_maker.class
DEL InptScherm.class
DEL ReedAntRite.class

javac XFile_maker.java
jar -cvmf manifest.txt X_file.jar *.class


You say to put the jar file in the CLASSPATH. Does that mean in the same map as the rest of my source code?
I've tried this (with "import UniversalDetector;") but it doesn't work.
Or do I have to adjust the CLASSPATH Systemvariable. Currently set as ".;C:\Program Files\Java\jre6\lib\ext\QTJava.zip"

10 years ago
I've downloaded "juniversalchardet-1.0.3.jar" to my C:\Program Files\Java\jre6\lib

I've added it to my PATH variable

C:\Program Files\Java\jdk1.6.0_23\bin;C:\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar;C:\Program Files\Java\jre6\lib\juniversalchardet-1.0.3.jar

But when I compile it doesn't recognize the UniversalDetector class..

UniversalDetector detector = new UniversalDetector(null);

I'm a bit stumped.

10 years ago
Thankyou Paul for the fast reply.

I'm attempting option 1, but can't seem to locate the files I need.

import org.mozilla.universalchardet.UniversalDetector;

I believe what I need to do is to make a map structure in my own source map org\mozilla\universalchardet\UniversalDetector?
And then put some files in the UniversalDetector map? Is that correct?




10 years ago
I have made a working program which reads in a Questionaire file and converts it to a descriptions file for coding open answers.
The problem is that sometimes the Questionaire is in UTF-16 other times UTF-8.
I've "fixed" the problem by promting for a user input in a JTextField of either String UTF = 8 or 16.
As it is now, I input the 8 first. If the program fails I then try the 16.

fis = new BufferedReader(new InputStreamReader(new FileInputStream(inFile), "UTF-" + UTF));

I'd prefer it if the program could recognize the correct file format for me but I can't work out how to do this.
Can anyone give me some hints?

10 years ago

Yes!!!
Thanks a lot for your help.
Came close to quitting there for a while.
Microsoft Windows XP [versie 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Map van C:\Documents and Settings\Chris\Mijn documenten\java_2\0001Movie_databa
se_005

20-12-2011 13:28 <DIR> .
20-12-2011 13:28 <DIR> ..
20-12-2011 13:19 107 compileren.bat
20-12-2011 13:28 3.160 Database.class
02-09-2010 10:39 5.499 Database.java
20-12-2011 13:28 2.170 InpoetScreen.class
02-09-2010 11:04 2.307 InpoetScreen.java
20-12-2011 13:28 523 SchrijfNaarDatabase.class
02-09-2010 10:42 477 SchrijfNaarDatabase.java
20-12-2011 13:50 101 start.bat
9 bestand(en) 15.373 bytes
2 map(pen) 1.926.512.640 bytes beschikbaar

C:\Documents and Settings\Chris\Mijn documenten\java_2\0001Movie_database_005>st
art.bat

C:\Documents and Settings\Chris\Mijn documenten\java_2\0001Movie_database_005>ja
va -classpath C:\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar S
chrijfNaarDatabase
Exception in thread "main" java.lang.NoClassDefFoundError: SchrijfNaarDatabase
Caused by: java.lang.ClassNotFoundException: SchrijfNaarDatabase
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)
Could not find the main class: SchrijfNaarDatabase. Program will exit.
Thanks for your reply quick reply Rob,
I had tried some variations, but none seem to work really.

java -classpath C:\mysql-connector-java-5.1.6 SchrijfNaarDatabase

java -classpath C:\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar SchrijfNaarDatabase

java SchrijfNaarDatabase -classpath C:\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar

java SchrijfNaarDatabase -classpath C:\mysql-connector-java-5.1.6

I can't really figure out what I'm doing wrong.
versions 3 and 4 open my application allright, but still can't find the driver.


Hi,

I have installed C:\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar containing the JDBC driver.class
When I run a certain java application I made (years ago) and press a button to submit a new record to a database I get...

Could not load JDBC driver: java.lang.ClassNotFoundException:com.mysql.jdbc.driver

Now I know I need to do something with classpath, but I don't have a CLASSPATH system variable, and I've read that I shouldn't make one either.
I've tried adding the .jar to User variable PATH but this doesn't seem to work either.

PATH C:\Program Files\Java\jdk1.6.0_23\bin;C:\mysql-connector-java-5.1.6\mysql-connector-java-5.1.6-bin.jar

NowI run the java program with a batch file which simply contains
java SchrijfNaarDatabase
should I add a -classpath instruction in this batch maybe so that the application can find the .jar file?

I've been searching for the solution on internet for many hours over many days and feel kinda foolish for not being able to work it out.
I know this app used to work in the past, but somehow it doesn't anymore.

I would greatly appreciate it if someone could give me some advice.





Thanks guys, huge help.

Never considered the possibility of passing the JTextField to the other class. Brilliant, it works!
15 years ago
Hello all,

I have made a program where a JFrame gets created with TextFields to hold scores and a bunch of buttons which change those scores.

Under some circumstances I need the user to type in a score and I've made it so that when a combination of buttons is pressed, another JFrame gets created. This 2nd JFrame contains another TextField and an enter button.

I need for the score in this TextField to be added to the score in the TextField in the original JFrame upon pressing the enter button but I have been unable to achieve this.

Does anyone have any advice they could give me?

Thanks,
Onslow
15 years ago
Yes, I'm starting to catch on.

I think I'll try using ArrayList to solve the problem.

I'd already declared one in the previous example but that was as far as I'd gotten with that. I knew of their existance but have never used them before.
I've been kinda avoiding arrays altogether, but I guess it's time to face
that demon. ;-)

Thanks for your help!
16 years ago
Thanks Ernest,

I'll do my best to adhere to Java naming Convention in future.

What I'm trying to achieve is to declare MakePlayer variables according to a Player.txt file I've created, as opposed to naming every player in the class itself.

I'm gonna call a getPlayerName method but am trying to work out where to call it. The program worked initially with the declaration\initiallisation within the class body but I've been unsuccesfull in using the getPlayerName method to achieve the same result.
Therefore I'm now testing the initialisation within the method, but because I need the objects outside that method I'm running into trouble.
16 years ago
Hi Jeanne,

Wow, that was speedie. Thanks for that.
You made me re-examine the program and it seems the error occurs outside the constructor, at button event. How do I get around this problem, when I can't make the objects public, when I declare them within the constructor?


public void actionPerformed(ActionEvent e)
{
if (e.getSource()==jbPlayGame)
{
Chrissie.setNameActive(0);
Wichie.setNameActive(0);
Ancie.setNameActive(0);
Frankie.setNameActive(0);
Stevie.setNameActive(0);
Coenie.setNameActive(0);
Piet_Heijnie.setNameActive(0);
Strangie1.setNameActive(0);
Strangie2.setNameActive(0);
16 years ago
Hello,

When I declare my "MakePlayer" objects outside the constructor my program compiles and runs ok. However when I try to declare them within the constructor, I get errors when I use setNamePlayer method.
Is there someone that can explain this to me?





[edited to add code tags to preserve indentation]
[ October 28, 2007: Message edited by: Jeanne Boyarsky ]
16 years ago