Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
yatagan
Aug 31, 2009

by Ozma
What is going on with com.sun.security.auth.module.NTSystem? It's not in my rt.jar, and it's not in a fresh JRE download from Sun.

Edit: ughhhhh

OK, they don't give it out on their Linux distributions. What a mess, even if it won't run on Linux they should at least let me compile the byte code on Linux.

yatagan fucked around with this message at 09:31 on Jan 29, 2010

Adbot
ADBOT LOVES YOU

zootm
Aug 8, 2006

We used to be better friends.

yatagan posted:

OK, they don't give it out on their Linux distributions. What a mess, even if it won't run on Linux they should at least let me compile the byte code on Linux.
You should not be writing code depending on com.sun._ packages, it's not supported and they vary between versions and distributions. Of course it's temptong since there's extra capabilities in there. What are you trying to do?

yatagan
Aug 31, 2009

by Ozma

zootm posted:

You should not be writing code depending on com.sun._ packages, it's not supported and they vary between versions and distributions. Of course it's temptong since there's extra capabilities in there. What are you trying to do?

I need to verify the user is logged into a particular Windows domain. An internal JRE is provided with the app, so versioning isn't a user issue.

zootm
Aug 8, 2006

We used to be better friends.

yatagan posted:

I need to verify the user is logged into a particular Windows domain. An internal JRE is provided with the app, so versioning isn't a user issue.
Ack. Well I guess the problem is you're writing Windows-specific code using internal APIs. You'll probably need to compile on Windows. Since tests wouldn't run properly outside of Windows maybe that's for the best.

yatagan
Aug 31, 2009

by Ozma

zootm posted:

Ack. Well I guess the problem is you're writing Windows-specific code using internal APIs. You'll probably need to compile on Windows. Since tests wouldn't run properly outside of Windows maybe that's for the best.

Yeah, I tried hacking the NT class files into the jar to get it to compile, but it was easy to see early on that was going to be more trouble than running a svn checkout and installing eclipse on a windows box. Up and running now, good thing only our developers have linux boxes I suppose.

zootm
Aug 8, 2006

We used to be better friends.

yatagan posted:

Yeah, I tried hacking the NT class files into the jar to get it to compile, but it was easy to see early on that was going to be more trouble than running a svn checkout and installing eclipse on a windows box. Up and running now, good thing only our developers have linux boxes I suppose.
I suppose so. I guess if you're writing platform-specific code, though, the devs are just gonna have to have that platform. Interesting that there isn't an obvious way to do this generically, I guess domains maybe don't generalise all that well.

csammis
Aug 26, 2003

Mental Institution

zootm posted:

I suppose so. I guess if you're writing platform-specific code, though, the devs are just gonna have to have that platform. Interesting that there isn't an obvious way to do this generically, I guess domains maybe don't generalise all that well.

There are definitely cross-platform LDAP connectors, but I don't know of any in Java (the one my company uses is C). A little bit of native library + JNI could solve the problem.

zootm
Aug 8, 2006

We used to be better friends.

csammis posted:

There are definitely cross-platform LDAP connectors, but I don't know of any in Java (the one my company uses is C). A little bit of native library + JNI could solve the problem.
Well you may as well grab the class you like using reflection if you want to do the JNI path, you're still constrained to one working platform. And yeah, LDAP is pretty well-supported on Java, but that's orthogonal to the issue of Windows Domains, unless you have LDAP integrated, which I don't think is guaranteed.

csammis
Aug 26, 2003

Mental Institution
Actually I just realized I read his problem incorrectly...LDAP can tell you if a user exists in a domain (as long as it is based on Active Directory, I think) but I don't believe it can tell you if the user is logged in. Oh well :)

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:31 on Mar 13, 2017

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Several ways to do it I guess. I would probably do a nextInt() mod 2. If 0 multiply the random double by -1, else just leave it positive

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
At first I was rather confused by OBD's suggestion, but I think I understand what he's getting at.

The simple way is to do ((Math.random() * 2) -1).

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
There's this perfectly reasonable nextBoolean() sitting right there, which you can use instead of nextInt() % 2. But you shouldn't use it for this! Instead, you should think about how you can use simple math to transform one range of numbers into another.

For example, nextDouble() gives you something in the range [0,1]. How can you use that to get a number in the range [1,2]? or [100,101]? or [-100,-101]? Similarly, how can you turn a random number in the range [0,1] into a random number in the range [0,2]? or [0,100]? or [0, 10000]? Now put those two ideas together.

EDIT: beaten with the solution, but still, this should be helpful

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Internet Janitor posted:

The simple way is to do ((Math.random() * 2) -1).

yea, this is much better, don't answer in this thread while on the phone...


fake edit: if you think about it this would be less random then Random is already is because the least significant digit will always be even, theoretically (in my mind) at least.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I was thinking the reason you were doing it your way was because my way just stretches and shifts the output range of Math.random()- since ultimately we're dealing with floating point numbers (approximations), the granularity of the output will be lowered. If my approach distributes n possible values from -1 to 1, yours distributes 2n possible values over the same space, right?

edit: yeah, thinking about it more this is pretty much exactly what you meant about the least significant digit.

so, elegantly:

Random randy = new Random();
double value = ((randy.nextBoolean() ? 1 : -1) * (randy.nextDouble()));

Internet Janitor fucked around with this message at 04:23 on Jan 30, 2010

8ender
Sep 24, 2003

clown is watching you sleep
This is pretty specific question but has anyone figured out a way to remote deploy to a Weblogic server using Netbeans? I've fallen in love with the simplicity of Netbeans over jDeveloper but the lack of Weblogic remote deploy is going to be a dealbreaker for using it at work.

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:31 on Mar 13, 2017

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
I have no loving clue how that helps you.... that just simulates rolling a dice.

Use this

InternetJanitor posted:

Random randy = new Random();
double value = ((randy.nextBoolean() ? 1 : -1) * (randy.nextDouble()));

Or this which is probably what he would expect.

InternetJanitor posted:

double value = ((Math.random() * 2) -1);

e: I just remembered I had this exact same assignment but it was on problem on our test and no one had a clue how to solve it.

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:31 on Mar 13, 2017

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
GregNorc: For the record, the Javadoc specifies that

code:
Random rnd = new Random();
Uses the current time as a seed, making it identical to this:

code:
Random rnd = new Random(System.currentTimeMillis());
Furthermore, assuming you don't need the methods exposed by java.util.Random, Math.random() is a superior choice because you can use it without importing any classes (Math is in java.lang) and while it internally uses a Random, it's synchronized- since all requests from any thread will access the same generator, you avoid the problem where a bunch of things initialize generators at about the same time and wind up with the same random sequences.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

osama bin diesel posted:

fake edit: if you think about it this would be less random then Random is already is because the least significant digit will always be even, theoretically (in my mind) at least.

This is not how floating-point works; multiplying by two will adjust the exponent without losing any precision from the significand. Subtracting by 1 could, in theory, lose precision on numbers close to 0; I don't remember whether nextDouble() makes an effort to give you extra precision there. At any rate, it should not affect the overall distribution.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
rjmccall: you aren't losing any precision in a numerical sense, but you are spreading a fixed number of possible values over a greater range. When you multiply by two, the exponent won't "grow" another random bit- it will shift in a zero.

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Internet Janitor posted:

rjmccall: you aren't losing any precision in a numerical sense, but you are spreading a fixed number of possible values over a greater range. When you multiply by two, the exponent won't "grow" another random bit- it will shift in a zero.

I agree that the randomly-negate method has 2^54 possible values whereas the scale-and-shift method only has 2^53. I just want to note that (1) this is not because precision is lost by scaling or shifting, which previous posts had implied, and (2) it does have the disadvantage of doubling the likelihood of 0.

These differences are also totally irrelevant because the first thing GregNorc is going to do with this number is square it, i.e. he really doesn't need to adjust the output of nextDouble() at all.

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:31 on Mar 13, 2017

epswing
Nov 4, 2003

Soiled Meat
So just to clarify, your program is only given e as input, yes?

maskenfreiheit
Dec 30, 2004
...

maskenfreiheit fucked around with this message at 03:44 on Sep 29, 2010

Volguus
Mar 3, 2009
I'm not sure i understand. Why do you need to verify if a^5 + b^5 + c^5 + d^5 = e^5 ?
I mean...you can calculate e. lets take a,b,c,d=1, you then have:
4=e^5
e=Math.pow(4,0.2)

and so on and so forth(for different a,b,c and d values).
But, you still need to have a lower and an upper limit. And that limit is going to determine how long it will take.

epswing
Nov 4, 2003

Soiled Meat
Maybe the values he needs to find must all be integers.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
I'm trying to find a good tutorial on using the org.w3c.dom stuff to output HTML. Is this not the correct tool for what I want to do? Or is there a template engine I should look at?

edit: I found StringTemplate, looks like it should do just fine.

fletcher fucked around with this message at 23:57 on Feb 1, 2010

maskenfreiheit
Dec 30, 2004
...

maskenfreiheit fucked around with this message at 03:44 on Sep 29, 2010

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:32 on Mar 13, 2017

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
GregNorc: well, the simple answer is what the compiler is telling you- "a" isn't a statement, right?

code:
int a = 0;
for(a; a < 5; a++) {foo(a);}
won't compile.

code:
int a = 0;
for(; a < 5; a++) {foo(a);}
will compile. What is the difference here?

edit:

Y'know, I looked over your code again, and I don't think you're doing what you think you're doing. You mean to do a brute-force search, right?

Reread what rhag was telling you about upper limits and step through those loops by hand.

Internet Janitor fucked around with this message at 03:15 on Feb 2, 2010

Azerban
Oct 28, 2003



I've got an applet embedded in a webpage that works perfectly on Windows machines, but absolutely nothing shows up on Linux machines, just a blank page. Any idea what could be causing this?

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Azerban posted:

I've got an applet embedded in a webpage that works perfectly on Windows machines, but absolutely nothing shows up on Linux machines, just a blank page. Any idea what could be causing this?

Did you set up Firefox or whatever to use the Java plugin? about :plugins to check

You have to do it manually in linux

DotSlayer
Jan 30, 2010

GregNorc posted:

yeah the prof said to use integers for all the variables

The way he has us do it is write a method that returns power of 5.

(so say, exp(x) returns x^5)

Then using some sort of combination of loops, iterate over a, b, c, d, and e until you finds a case where a^5 + b^5 + c^5 + d^5 = e^5

(a b c d and e are all positive integers, specifically the data type "long")

At the very first glance if you are talking about positive integers except nil the answer is empty set. Looks really close to http://en.wikipedia.org/wiki/Fermat%27s_Last_Theorem. The only difference is number of summands. Grab someone really good in math he should know the answer)

DotSlayer
Jan 30, 2010

GregNorc posted:

... skipped

code:
//Need these for printWriter, parseLong, etc:
import java.lang.*;
import java.io.*;


public class problem1{ //note that we have to allow the exception below
	public static void main(String[] args) {
		//initialize variables
		long a = 1;
		long b = 1;
		long c = 1;
		long d = 1;
		long e = 1;

        long maxLimit = 10000000;

		for (; a <= maxLimit; a++){
			if (expSum(a,b,c,d) == exp(e))
				break;
			for (; b <= maxLimit; b++){
				if (expSum(a,b,c,d) == exp(e))
					break;
				for (; c <= maxLimit; c++){
					if (expSum(a,b,c,d) == exp(e))
						break;
					for (;  d <= maxLimit; d++){
						if (expSum(a,b,c,d) == exp(e))
							break;
						for (; e <= maxLimit; e++){
							if (expSum(a, b, c, d) == exp(e))
								break;
						}
					}
				}
			}
		}

	//NOTE TO SELF: MAKE SURE TO CHANGE THIS PRINT STATEMENT TO OUTPUT TO FILE
	//BEFORE TURNING IN PROGRAM! (KEEP SIMPLE FOR DEBUGGING RIGHT NOW)
	System.out.println("WIBBLY WOBBLY. TIMEY WIMEY. WE HAVE A SOLUTION.");
	System.out.println("PROBABLY COULD BE MORE EFFICIENT.");
	System.out.println("BUT DOWN THAT ROAD LIES ONLY SORROW AND RAGE");
	System.out.printf("A: %d\tB: %d\tC: %d\tD: %d\tE: %d", a, b, c, d, e);
	System.out.println("HEY! GREG! DID YOU REMEBER TO CHANGE THIS TO OUTPUT TO A FILE? OBVIOUSLY NOT!");
	}
	// returns the value of a numbr to the power of 6
	public static long exp(long number){
		long exponent = number * number * number * number * number;
		return exponent;
	}

	//computes sum of a^5 + b^5 + c^5 + d^5...
	//not _technically_ nessecary, but sure helps readability!
	public static long expSum(long a, long b, long c, long d)
	{
		long sum = exp(a) + exp(b) + exp(c) + exp(d);
		return sum;
	}
}

fixed. take a look.I did nothing to your program flow daresay it sucks as hell.

DotSlayer
Jan 30, 2010

Azerban posted:

I've got an applet embedded in a webpage that works perfectly on Windows machines, but absolutely nothing shows up on Linux machines, just a blank page. Any idea what could be causing this?

Maybe your browser on linux machine just doesn't support java applets? Just like for windows you have to install that jre/jdk and checkbox browsers you've got. Otherwise you are out of luck.

lewi
Sep 3, 2006
King

DotSlayer posted:

At the very first glance if you are talking about positive integers except nil the answer is empty set. Looks really close to http://en.wikipedia.org/wiki/Fermat%27s_Last_Theorem. The only difference is number of summands. Grab someone really good in math he should know the answer)

You can't take Fermat's last theorem and generalise it for all numbers of summands.
27^5 + 84^5 + 110^5 + 133^5 = 144^5 is proof enough.

DotSlayer
Jan 30, 2010

lewi posted:

You can't take Fermat's last theorem and generalise it for all numbers of summands.
27^5 + 84^5 + 110^5 + 133^5 = 144^5 is proof enough.

that was just a wild guess. thanks.

Adbot
ADBOT LOVES YOU

Fly
Nov 3, 2002

moral compass
GregNorc, keep in mind that

(6209 ^ 5) - ((2 ^ 63) - 1) = 4643121256274242

while

(6208 ^ 5) - ((2 ^ 63) - 1) = -2785645994967039


You don't want to loop to Long.MAX_VALUE.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply