Matthew Mellott

Greenhorn
+ Follow
since Nov 29, 2010
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 Matthew Mellott

So I've been trying to post to this url. Every diffrent way I try it I get the same errors:



I have no idea what these errors mean, let alone how to fix them. Here's my code:



I've used the SSLSocket class before without getting this error. I also tried implementing the above code using an SSLSocket and got identical errors to the ones above.
Thanks for the help!
Thanks for pointing me to that library! It's free, easy to use, and does exactly what I want it to. Wow.
13 years ago
Are there any free windows JNI libraries (I'm not exactly sure if that's what you would call them)? Something like the WinPak that comes with JNIWrapper from teamdev.com. I want to be able to get "hotkey" input when my swing application does not have focus.

I tried to write my own native method, but my C/C++ could barley be considered to be at a beginner level.

Thanks!
13 years ago
Ok, here's some more pseudo code. I am making the assumption that Units also have a unitId that corresponds to the subunits unitId (if they don't, then you need to find some way of make the subunits unitId correspond to the units position in the linked list). So below I use parallel linked lists (ll), sort of. The first ll is of units. The second ll is a ll of lls of subunits. The index of the each unit in the first ll corresponds to the ll of its subunits in the second ll.Hope this helps.
13 years ago
Look into variable scope. The i in your main method and the i in the other class exist in two completely different scopes based upon where they are declared.
13 years ago

Rob Prime wrote:Only through reflection, and only if the security manager allows it. In general, it's a case of bad design - either by the person that created the class for not providing getters / setters or by you for trying to access something you really shouldn't. (Usually it's the former.)


If a data member is private, then following won't work:
object.privateMember; //error, privateMember is private

Like Rob said above, if you are supposed to have access to this data then there will be a getter method, and it will probably look something like this:
object.getPrivateMember();

If you can't find a method like the one above, then someone needs to consider redesigning something.
13 years ago
Can you be more specific and post some code? For instance, where are you getting input?

Also, from what you have said so far, I think you might find LinkedLists helpful. Here is a brief overview.
13 years ago
Here is some pseudo-code if that helps.
13 years ago
Yup, I would not not plan on distributing a command line application (those are just sketchy nowadays).
13 years ago

Campbell Ritchie wrote:A jar is usually opened with a program called javaw which does not open a console or terminal.


Oh ok that makes sense. So I guess the fix is simpler then I thought, you just have to tell windows to open it with java.exe instead of javaw.exe.

Thanks!

Edit: here is how I finally got around this problem if anyone else is interested (this is all in windows).

Since I didn't want all jar files to be opened with java.exe (who wants a console popping up when you have a flashy gui?), I just added a right click option to jar files that says "open in console" and causes the jar file to be opened with java.exe. I did this by just quickly going in to the registry; click here for more info.

If you don't care about having the console popping up every time you double click a jar file, you can use the following in cmd.exe to make jar files open with java.exe:

ftype jarfile=java.exe -jar "%1"
(this is assuming you have your classpath set already and jarfile is already associated with .jar. google classpath, assoc, and ftype for more info.)

Hope this helps someone.

13 years ago
Ok, so I did some more googling and finally found an answer:

A JAR is a great way of packaging and deploying a Java SE project. But there is a problem with console input/output--the standard I/O files (System.out, System.err, and System.in) do not work when a JAR is activated by a double-click. System.out and System.err are simple, intuitive, and frequently used for problem reporting, and their loss can be quite inconvenient.

http://today.java.net/article/2006/01/27/console-terminal-jars


So basically there is no "easy" solution to this problem. The website offers an open source tool that they say you can use to fix the problem without changing any code.

edit: so i'm no longer sure what this webiste is talking about anymore. setting .jar files to opened with java.exe when you double click them works fine for console programs and therefore their solution seems overly complicated.
13 years ago
To spice things up, you can change args to cheese:

public static void main(String cheese[])

This does not change the method signature, and, as others have said above, the main method with the above signature is specifically looked for as the entry point of your application.
13 years ago
Thanks for welcoming me to the ranch.

So now I'm having a diffrent problem. When I double click the jar file, its saying that it can't load my Main-Class manifest attribute. Here is my code:

MANIFEST.MF:

build.bat:

test.java:
13 years ago
My problem: the console is not opening when I double click my jar file.

When I run the jar file from command prompt (using >java -jar Main.jar), everything works the way I expect it to.

Here is the batch file I use to build my program (I was originally using eclipse but I encountered this same problem and thought eclipse was to blame):

Here is the Main.java file(just an example):

So, in other words, can you add something that forces the console to open?
13 years ago