Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Windows command line Error(SOLVED),but how to add LWJGL?  (Read 574 times)
0 Members and 1 Guest are viewing this topic.
Offline Doubstract
« Posted 2013-12-10 11:09:21 »

I am trying to create a runnable jar file. I am using multiple classes and packages.

Windows 7 32-bit. jdk1.7.0_17. jre7.

I am using windows prompt, because i guess there is no other way to create runnable jar file with multiple classes. Right now i am getting this:
C:\Users\Admin\LudumDareDone\bin>java -jar "ludum.jar"
Error: Could not find or load main class Main

i have this manifest:
Manifest-Version: 1.0
Created-By: <Your info>
Main-Class: Main.java


i applied it with this command:
jar cfm ludum.jar manifest.mf


What i should do? Maybe there is other way to create runnable jar file with multiple classes? I searched answer in Google, but i cant find anything usefull, please give me direct links or answer.
Offline xsvenson
« Reply #1 - Posted 2013-12-10 11:34:39 »

IDEs have the option to generate a runnable jar from Your project.
Your current issue is that You need to define a fully qualified class name: "com.my.package.Main"
Class is the the class object, the structure You are using within Your program, as such "Main.java" is not what is needed in that location.

“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline Doubstract
« Reply #2 - Posted 2013-12-10 11:52:43 »

Sorry for stupid question, but i think i am doing something wrong here. What is fully qualified class name?
Currently, i have this:
MyJavaProject
----src
--------(default package)
------------Main.java

How fully qualified class name should look like?


EDIT:
i am using eclipse
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2013-12-10 12:00:35 »

Hi

Rather put that into your manifest:
Quote
Main-Class: Main

Whatever your IDE is, try to understand what happens under the hood.

Offline xsvenson
« Reply #4 - Posted 2013-12-10 12:02:20 »

Fully qualified class name consist of package name and class name. As in my previous post "com.my.package" is package name and "Main" is the class name.
Package translates 1:1 to the folder structure, so for the given package "com.my.package" the folder structure would be like this

Project
  |_ src
      |_ com
            |_ my
                 |_package
                     |_ Main.java

In Your example, You are not using package so Your fully qualified class name is the same as the simple form "Main"
http://en.wikipedia.org/wiki/Fully_qualified_name

Why package names ? It's a form of namespace. Imagine using 7 different libraries, non using packages and everyone having a "Main" class. How would You tell Your program, which one to use ?
That's why there are packages. All libraries and programs in java world are in packages. There are also other benefits
http://docs.oracle.com/javase/tutorial/java/package/index.html


“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Offline gouessej
« Reply #5 - Posted 2013-12-10 12:17:24 »

I just meant that ".java" has nothing to do in the manifest attribute "Main-Class".

Offline Damocles
« Reply #6 - Posted 2013-12-10 12:34:17 »

try a manifest:

----
Manifest-Version: 1.0
Class-Path: .
Main-Class: Main
----

using the manifest name

MANIFEST.MF
in the folder META-INF

Offline Doubstract
« Reply #7 - Posted 2013-12-10 12:51:30 »

Now i think i have another problem:

Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLExcept
ion
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)
        at java.lang.Class.getMethod0(Class.java:2694)
        at java.lang.Class.getMethod(Class.java:1622)
        at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)

Caused by: java.lang.ClassNotFoundException: org.lwjgl.LWJGLException
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
        ... 6 more


EDIT:
What i should do? Where is problem? Or maybe there is another way to create runnable jar file with multiple classes?
Offline Doubstract
« Reply #8 - Posted 2013-12-10 16:00:47 »

I think i finaly done that, but i tried simple program with pure java. I want to add lwjgl. How i should do that?
Offline gouessej
« Reply #9 - Posted 2013-12-10 17:02:43 »

It's explained here:
http://docs.oracle.com/javase/tutorial/deployment/jar/downman.html

Quote
Class-Path: MyUtils.jar

Edit.: Don't forget to do something for the native libraries.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Doubstract
« Reply #10 - Posted 2013-12-10 18:45:16 »

Maybe you, or somebody else know other tutorial? I would like more examples and maybe something what i can try instant.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (34 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!