|
I'm trying to figure out the best way to share an Eclipse project. The folder is on a shared drive (shared via Dropbox), with one computer on Mac OS X and the other using Windows 7. When I try just pointing Eclipse to the folder as the workspace to open, I get bunch of "file not found" errors, and an empty project. I'd rather not put the project into version control right now since it's just a small, personal project at the moment. Also, my VCS of choice (Git) kinda sucks on windows.
|
# ? Aug 22, 2010 00:33 |
|
|
# ? May 25, 2024 14:47 |
|
Magicmat posted:I'm trying to figure out the best way to share an Eclipse project. The folder is on a shared drive (shared via Dropbox), with one computer on Mac OS X and the other using Windows 7. Use mercurial with tortoisehg if you still want a decent DVCS on windows. There isn't any excuse.
|
# ? Aug 22, 2010 00:50 |
|
MEAT TREAT posted:Use mercurial with tortoisehg if you still want a decent DVCS on windows. There isn't any excuse. But that's getting off topic Is there an easy way to just open a Eclipse workspace on another system?
|
# ? Aug 22, 2010 01:06 |
|
Just right click the project in the Project Explorer, export to zip, save the file into dropbox. Then open eclipse on the other machine, right click empty space in Project Explorer (I think), import, select the zip file. Magicmat posted:I'm a Git man, though. Oh quit moaning. For everyday use, the ideas (and many commands) are nearly the same. It's a chance to learn another DVCS. On your next job interview, you can say "yes, I know Mercurial basics." When you want to contribute to a project on BitBucket, you'll know what's going on. What have you got to lose, exactly?
|
# ? Aug 22, 2010 01:55 |
|
Maybe it would work using a local workspace on the Windows machine, then Import...->Existing Projects into Workspace, point it to \My Dropbox and then tell it to not copy the project files to the workspace? I don't think putting the workspace itself to Dropbox is a good idea.
|
# ? Aug 22, 2010 02:25 |
|
^^ Agreed. Honestly, I'd like into using something that's IDE-agnostic, such as Maven, to build your project. It has an Eclipse plugin that can be used to generate Eclipse project artifacts by reading the project's POM.
|
# ? Aug 22, 2010 16:54 |
|
Chairman Steve posted:Honestly, I'd like into using something that's IDE-agnostic, such as Maven, to build your project. This sentence started with such great potential... (I don't mean that Maven wouldn't be IDE-agnostic, it's more like reality agnostic).
|
# ? Aug 22, 2010 18:44 |
|
A quick question from a C++ guy who is dipping his toes into Java. If I have two preallocated objects, is there a convenient way to do a deep copy of one into the other, avoiding allocating a new one? I really want something a bit like clone() but with an existing target.
|
# ? Aug 22, 2010 21:23 |
|
danishcake posted:A quick question from a C++ guy who is dipping his toes into Java. If I have two preallocated objects, is there a convenient way to do a deep copy of one into the other, avoiding allocating a new one? I really want something a bit like clone() but with an existing target. If you are not opposed to using an external class the Apache Commons BeanUtils class has the copyProperties method that does what you want. But that if you have non primitive fields inside, it will probably just copy the references and not do a deep copy like you would expect.
|
# ? Aug 22, 2010 21:38 |
|
Parantumaton posted:This sentence started with such great potential... (I don't mean that Maven wouldn't be IDE-agnostic, it's more like reality agnostic). Eh? Care to elaborate?
|
# ? Aug 22, 2010 22:29 |
|
I'm having trouble with reading a webpage via a URLConnection object using a proxy. I'm using a Proxy object with the url.openConnection(proxy) method. My code is designed to test a bunch of proxies, so what it's supposed to do is just try to access the same web page over and over, with a new proxy each time. Each proxy has no guarantee of being functional in any way (hence why I'm testing them.) The problem is that Java seems to do it's own thing in terms of my proxy settings. For example, I have it setup to connect with no proxy, proxy A, proxy B and proxy C. My webserver's logs, however, show it being accessed with no proxy, no proxy, proxy B and proxy B. Sometimes it's no proxy, proxy A, proxy A, proxy C; or some other random combination. What's going on here? Why is Java holding over old proxy info when I'm setting it on a per-connection basic? You can see my horrible, messy, prototype-quality code here. Magicmat fucked around with this message at 22:10 on Aug 23, 2010 |
# ? Aug 23, 2010 21:51 |
|
Is it in any way possible that it has something to do with Java's caching of DNS resolution[1]? http://myhowto.org/java/42-understanding-host-name-resolution-and-dns-behavior-in-java/
|
# ? Aug 24, 2010 01:27 |
|
Chairman Steve posted:Is it in any way possible that it has something to do with Java's caching of DNS resolution[1]? code:
If there's no way around this, I may just write my own proxy-capable basic HTTP class over a Socket. Kinda sucky, but I'm not sure what else to do.
|
# ? Aug 24, 2010 06:40 |
|
Magicmat posted:You can see my horrible, messy, prototype-quality code here. You're not closing the connections or streams properly, so they might be closed only when the program terminates. This could affect the order and timestamps of the log entries the webserver outputs. Also, try adding a 10 second delay between testing different proxies to see whether the duplicate log entries come from the same or different proxies.
|
# ? Aug 24, 2010 07:26 |
|
I am in posted:You're not closing the connections or streams properly, so they might be closed only when the program terminates. This could affect the order and timestamps of the log entries the webserver outputs. Thanks for the help!
|
# ? Aug 24, 2010 08:03 |
|
I'm pretty familiar with object-oriented Python and I used to use do some object-oriented C++ years ago so the Java syntax looks somewhat familiar to me. What are some are good resources for learning Java if I'm already pretty familiar with object-oriented design? I found this interesting site which I'm going through now but wouldn't mind picking up a book if there are any good suggestions.
|
# ? Aug 24, 2010 19:31 |
|
A good habit to get into is to close all streams in a finally block:code:
code:
|
# ? Aug 25, 2010 16:58 |
|
fletcher posted:How come something like this works: Because the Java compiler is interpreting {"stuff"}; as a static initializer in the first case, and a block of code in the second, which makes no lexical sense. You could replace the second case with return new String[]{"stuff"}; and it should work fine.
|
# ? Aug 26, 2010 01:48 |
|
omlette-a-gogo posted:In fact I do this so often I wrote a helper class that I am always reusing: http://commons.apache.org/io/api-release/org/apache/commons/io/IOUtils.html#closeQuietly(java.io.InputStream) Learn to love Apache commons! Or for some Java 6 goodiness: http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/io/Closeables.html#closeQuietly(java.io.Closeable)
|
# ? Aug 26, 2010 03:09 |
|
I'd still prefer to get RAII / RAII-like conventions like C#'s using, although Closeables could be turned into syntactic sugar like for ( : ) loops, but given the history of the JSRB, I only expect after Always hoped to have something like a synchronized block become an arbitrary block reflecting the scope of an object's lifetime with the end of the block automatically invoking the finalize method. But... garbage collection and
|
# ? Aug 26, 2010 09:25 |
|
JDK7 will have automatic resource management.
|
# ? Aug 26, 2010 13:25 |
|
When's that coming out, again?
|
# ? Aug 26, 2010 15:01 |
|
I'm trying to have a Vector array with four Vectors containing four different types of objects that are all subclasses to the same superclass, so that I could refer to the Vectors with index numbers. This is how I'm trying to do it:code:
I'm very new to this whole Java thing - actually to programming in general - so I could be missing something obvious or trying to do this in a completely retarded way, I just don't know! Is this even possible, or is the type safety warning harmless? edit: the exact type safety warning is "Type safety: The expression of type Vector[] needs unchecked conversion to conform to Vector<SuperClass>[]" TURTLE SLUT fucked around with this message at 15:44 on Aug 26, 2010 |
# ? Aug 26, 2010 15:38 |
|
Mustach posted:When's that coming out, again? You could theoretically start using it now, although I'm not sure how much of the Java TCK it actually passes. I'm hoping the one good thing to come out of the Oracle buy-out is a more intent focus on getting this poo poo out the door.
|
# ? Aug 26, 2010 15:52 |
|
Cukel posted:I'm trying to have a Vector array with four Vectors containing four different types of objects that are all subclasses to the same superclass, so that I could refer to the Vectors with index numbers. This is how I'm trying to do it: You can't create generic arrays in Java. The warning isn't something to be terribly worried about, as long as you're sure you're putting correctly subclassed vectors into the array. More specifically, you probably should do something like: code:
However, if you do this: code:
Kilson fucked around with this message at 16:26 on Aug 26, 2010 |
# ? Aug 26, 2010 16:09 |
|
Parantumaton posted:JDK7 will have automatic resource management. Any chance for a link on that? Can't seem to find it on the Sun^wOracle website.
|
# ? Aug 26, 2010 16:19 |
|
Kilson posted:You can't create generic arrays in Java. code:
|
# ? Aug 26, 2010 16:22 |
|
Cukel posted:Why is it a generic array? Just because I'm using Vectors? Because this gives the exact same warning: Can you not make a Vector<Vector<SuperClass>>?
|
# ? Aug 26, 2010 16:25 |
|
Cukel posted:Why is it a generic array? Just because I'm using Vectors? Because this gives the exact same warning: See my longer response above. A generic array would be something like code:
|
# ? Aug 26, 2010 16:28 |
|
Okay, thanks a lot for the help! Vector<Vector<SuperClass>> seems to work too and is much more fun, so I think I'm going to go with that. At least I tried it and didn't get any errors or warnings.
|
# ? Aug 26, 2010 16:34 |
|
OddObserver posted:Any chance for a link on that? Can't seem to find it on the Sun^wOracle website. It's called Project Coin. The proposal looks like to add a list of suppressed exceptions to Throwable, which deals neatly with the case where closing a resource throws an exception while another exception has already been thrown.
|
# ? Aug 26, 2010 17:27 |
|
Cukel posted:I'm trying to have a Vector array with four Vectors containing four different types of objects that are all subclasses to the same superclass, so that I could refer to the Vectors with index numbers. This is how I'm trying to do it: You are much better off redesigning this by implementing a new class containing the four vectors as member variables then putting in whatever methods you might need to manipulate or access them. Also consider using List unless there is a specific need for Vector. code:
|
# ? Aug 26, 2010 17:33 |
|
Cukel posted:Okay, thanks a lot for the help! Vector<Vector<SuperClass>> seems to work too and is much more fun, so I think I'm going to go with that. At least I tried it and didn't get any errors or warnings. Better is Vector<Vector<? extends SuperClass>>. But this datatype implies that whoever has a reference to it can do all sorts of stuff that you might not want them to do, like add/remove data from the vectors or add/remove entire vectors from the top-level vector. If there is any kind of structure or access control that needs to be enforced you should build it in to a new class and not rely on users to do the right thing.
|
# ? Aug 26, 2010 18:09 |
|
OddObserver posted:Any chance for a link on that? Can't seem to find it on the Sun^wOracle website. http://blogs.sun.com/darcy/entry/project_coin_updated_arm_spec http://blogs.sun.com/darcy/entry/project_coin_arm_implementation http://blogs.sun.com/darcy/entry/project_coin_try_out_try ...and a bunch of other stuff from that blog.
|
# ? Aug 26, 2010 21:09 |
|
omlette-a-gogo posted:Better is Vector<Vector<? extends SuperClass>>. But this datatype implies that whoever has a reference to it can do all sorts of stuff that you might not want them to do, like add/remove data from the vectors or add/remove entire vectors from the top-level vector. If there is any kind of structure or access control that needs to be enforced you should build it in to a new class and not rely on users to do the right thing. edit: of course I did not run any of this yet so I dunno if I'll get more problems then. Just going by what Eclipse is telling me. TURTLE SLUT fucked around with this message at 22:51 on Aug 26, 2010 |
# ? Aug 26, 2010 22:48 |
|
Cukel posted:Vector<Vector<? extends SuperClass>> This type effectively disallows both adding child vectors to it and adding elements to its child vectors. I don't know why it was suggested. Vector<Vector<SuperClass>> only works if the inner vectors have type Vector<SuperClass>. The reason why is complicated. Without question, you should be using a class with instance fields that have the appropriate vector types.
|
# ? Aug 26, 2010 23:31 |
|
rjmccall posted:This type effectively disallows both adding child vectors to it and adding elements to its child vectors. I don't know why it was suggested. It does work, but it's a meaningless argument, there has got to be a better way to model the data. Compressed to save space, not interested in finding out how many lines of code I can post before getting banned. code:
|
# ? Aug 26, 2010 23:55 |
|
rjmccall posted:This type effectively disallows both adding child vectors to it and adding elements to its child vectors. I don't know why it was suggested. Right now I have a separate class that contains the Vector<Vector<SuperClass>>, and it simplified the class a bit and seems to work as expected in some tests I did. I'm still really fuzzy on why this exact implementation works or if it's even supposed to work, but eh.
|
# ? Aug 27, 2010 00:14 |
|
omlette-a-gogo posted:A good habit to get into is to close all streams in a finally block: You can also use helper methods to handle all of the boilerplate: code:
code:
|
# ? Aug 27, 2010 00:31 |
|
|
# ? May 25, 2024 14:47 |
|
Or use the file-read methods of FileUtils[1] or Files[2]. 1. http://commons.apache.org/io/api-1.4/org/apache/commons/io/FileUtils.html#readLines(java.io.File) 2. http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/io/Files.html#readLines(java.io.File, java.nio.charset.Charset)
|
# ? Aug 27, 2010 03:07 |