Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Donny Nadolny

Ranch Hand
+ Follow
since Mar 05, 2003
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 Donny Nadolny

My compiler produces an error on all 4 of the options.
You could use JNI to write a wrapper for your application, and have that wrapper run as a service. I believe that should have the same effect.
17 years ago

Here we are rounding a value that actually should return Integer.MIN_Value-6 but an integer cannot hold such a small value so it rounds it to its minimum value Integer.MIN_VALUE


I don't believe that it's because an integer can't hold a small value - see the output from the following code:

The output will be a very large number (2.19 billion approx) because Java's numbers are signed - when you try to go too low, they loop around to be positive. I believe the answer to the question is the response I gave previously .
Hello. You want to calculate the GPA for 5 subjects, correct? All you are doing is getting the first and second argument passed to your program (String g = (args [0]); int c = Integer.parseInt (args [1]); ) . What you need to do is use a loop like:

If you need more help or if I wasn't clear enough, just reply and I'll try my best.
Edit: Some code was accidentally interpreted as an emoticon, changed spacing.
[ February 09, 2004: Message edited by: Donny Nadolny ]
17 years ago
Hey. The problem is that when you open a file to write to, it will erase the contents of that file and overwrite it with whatever text you want. Try instead to create a string (or StringBuffer if you want it more optimized) and instead of writing the file each time (subsequently overwriting each file name you write), just append the name of the file to a string (followed by the newline character, \n, of course). Then, write that text to the file containing all the file names. Hope this helps.
17 years ago
I don't think there is any way to do that using pure Java. If you're willing to use JNI, check out the API for SetWindowPosition (windows only).
17 years ago
Well, one way of activating some WinAmp function would be using the SendMessage API to make WinAmp think that a button has been pressed (eg play, pause, next, etc).
You'll need to find a program to spy on the messages winamp recieves (eg Spy++ included with MS Visual Studio 6 (perhaps lower vers too)). Then you can find out what message to send winamp. If you need more help, just post. Good luck.
17 years ago
I don't know much (anything) about JAAS, but perhaps your question could be answered from one of Sun's tutorials on JAAS, or by a google search for jaas java tutorial. Good luck.
Edit: I just re-read your post and saw that you were not running it through the netbeans IDE, so that changes my answer. Make sure that server1.class is in your classpath (try running it and fully qualifying the location of server1.class, ie "java.exe C:\java stuff\server program\server1".

I tried running it using my IDE and it worked fine. I *just* found out right now that NetBeans runs all programs in a certain directory (netbeans/bin) so perhaps this is messing it up? Check out the post here. Also, you could try running it simply using "java server1" when server1.class is in your java classpath. Good luck.
[ February 08, 2004: Message edited by: Donny Nadolny ]
17 years ago
That is interesting, I never knew the NetBeans IDE ran each program using its own directory. I'm glad you got it worked out.
17 years ago
To get a listing of all files in the current directory see this thread, actually its short enough that I might as well post the code again.

Now, rather than printing out the filename, you can use the string function (stringname).endsWith(".txt") to see if it has the .txt extention. That will give you all .txt files in the current directory. To do sub directories, you will need to loop through and (recursively) check each subsequent directory for txt files as well as more directorys.
If you need help with recusrion, check out a google search here.
If you need more help, just post.
17 years ago
Just to add to that, If your intention is to get a directory listing, there's a way using pure java to do it. Using a File object (passing the current directory) you can get a listing of all files and folders in the specified directory:

However, if your intention was to experiment with Runtime.exec() then follow Mark Vender's idea.
17 years ago
To get the current directory:

Example output: C:\My Java Stuff\Sample Programs\CurrentDir Program
From that, you could create a new file reader using the string containing the user's directory and append a slash (for windows) and then the filename.

<Edit>: By the way, I just checked, Java looks for a file in the current directory, so rather than using the code above you could simply use a file reader and pass the name of the file relative to the current directory.
[ February 08, 2004: Message edited by: Donny Nadolny ]
17 years ago
Perhaps I am missing something here, but why not just test your application and whenever anything goes wrong, add a catch statement for that exception and handle it?
Also, you could try to isolate sections of your code that are more prone to throwing exceptions and add a try {} catch (Exception e) { System.out.println(e);} around each of them, then when something goes wrong, your application doesn't crash and you are notified of the error.
17 years ago
Hey. The only thing I can think of right now is to read in the file, chance whatever you want to change, then write your new text (with your change) to the same file. As far as I can tell, that's the only way to do it (correct me if i'm wrong).
Hope this helps.
17 years ago